pub struct Extent(pub Range<u64>);Expand description
Extent represents a physical or logical range of bytes, aligned to a 512-byte boundary.
Tuple Fields§
§0: Range<u64>Implementations§
Source§impl Extent
impl Extent
Sourcepub fn overlap(&self, other: &Extent) -> Option<Range<u64>>
pub fn overlap(&self, other: &Extent) -> Option<Range<u64>>
Returns the range of bytes common between this extent and |other|.
Sourcepub fn search_key(&self) -> Self
pub fn search_key(&self) -> Self
Returns the search key for this extent; that is, a key which is <= this key under Ord and OrdLowerBound. This would be used when searching for an extent with |find| (when we want to find any overlapping extent, which could include extents that start earlier). For example, if the tree has extents 50..150 and 150..200 and we wish to read 100..200, we’d search for 0..101 which would set the iterator to 50..150.
Sourcepub fn search_key_from_offset(offset: u64) -> Self
pub fn search_key_from_offset(offset: u64) -> Self
Similar to previous, but from an offset. Returns a search key that will find the first extent that touches offset..
Sourcepub fn key_for_merge_into(&self) -> Self
pub fn key_for_merge_into(&self) -> Self
Returns the merge key for this extent; that is, a key which is <= this extent and any other possibly overlapping extent, under Ord. This would be used to set the hint for |merge_into|.
For example, if the tree has extents 0..50, 50..150 and 150..200 and we wish to insert 100..150, we’d use a merge hint of 0..100 which would set the iterator to 50..150 (the first element > 100..150 under Ord).
Sourcepub fn fuzzy_hash_partition(&self) -> ExtentPartitionIterator ⓘ
pub fn fuzzy_hash_partition(&self) -> ExtentPartitionIterator ⓘ
Returns an iterator over the Extent partitions which overlap this key (see FuzzyHash).
Methods from Deref<Target = Range<u64>>§
1.35.0 · Sourcepub fn contains<U>(&self, item: &U) -> bool
pub fn contains<U>(&self, item: &U) -> bool
Returns true if item is contained in the range.
§Examples
assert!(!(3..5).contains(&2));
assert!( (3..5).contains(&3));
assert!( (3..5).contains(&4));
assert!(!(3..5).contains(&5));
assert!(!(3..3).contains(&3));
assert!(!(3..2).contains(&3));
assert!( (0.0..1.0).contains(&0.5));
assert!(!(0.0..1.0).contains(&f32::NAN));
assert!(!(0.0..f32::NAN).contains(&0.5));
assert!(!(f32::NAN..1.0).contains(&0.5));1.47.0 · Sourcepub fn is_empty(&self) -> boolwhere
Idx: PartialOrd,
pub fn is_empty(&self) -> boolwhere
Idx: PartialOrd,
Returns true if the range contains no items.
§Examples
assert!(!(3..5).is_empty());
assert!( (3..3).is_empty());
assert!( (3..2).is_empty());The range is empty if either side is incomparable:
assert!(!(3.0..5.0).is_empty());
assert!( (3.0..f32::NAN).is_empty());
assert!( (f32::NAN..5.0).is_empty());Trait Implementations§
Source§impl<'de> Deserialize<'de> for Extent
impl<'de> Deserialize<'de> for Extent
Source§fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
Source§impl Ord for Extent
impl Ord for Extent
1.21.0 (const: unstable) · Source§fn max(self, other: Self) -> Selfwhere
Self: Sized,
fn max(self, other: Self) -> Selfwhere
Self: Sized,
Source§impl OrdLowerBound for Extent
impl OrdLowerBound for Extent
fn cmp_lower_bound(&self, other: &Extent) -> Ordering
Source§impl OrdUpperBound for Extent
impl OrdUpperBound for Extent
fn cmp_upper_bound(&self, other: &Extent) -> Ordering
Source§impl PartialOrd for Extent
impl PartialOrd for Extent
Source§impl SerializeKey for Extent
impl SerializeKey for Extent
Source§fn serialize_key_to<B: Buffer>(&self, serializer: &mut KeySerializer<'_, B>)
fn serialize_key_to<B: Buffer>(&self, serializer: &mut KeySerializer<'_, B>)
Source§fn deserialize_key_from(
deserializer: &mut KeyDeserializer<'_>,
) -> Result<Self, Error>
fn deserialize_key_from( deserializer: &mut KeyDeserializer<'_>, ) -> Result<Self, Error>
Source§impl TypeFingerprint for Extent
impl TypeFingerprint for Extent
fn fingerprint() -> String
impl Eq for Extent
impl StructuralPartialEq for Extent
Auto Trait Implementations§
impl Freeze for Extent
impl RefUnwindSafe for Extent
impl Send for Extent
impl Sync for Extent
impl Unpin for Extent
impl UnsafeUnpin for Extent
impl UnwindSafe for Extent
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
§impl<T, D> Encode<Ambiguous1, D> for Twhere
D: ResourceDialect,
impl<T, D> Encode<Ambiguous1, D> for Twhere
D: ResourceDialect,
§impl<T, D> Encode<Ambiguous2, D> for Twhere
D: ResourceDialect,
impl<T, D> Encode<Ambiguous2, D> for Twhere
D: ResourceDialect,
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
key and return true if they are equal.§impl<F, N> FidlIntoNative<Box<N>> for Fwhere
F: FidlIntoNative<N>,
impl<F, N> FidlIntoNative<Box<N>> for Fwhere
F: FidlIntoNative<N>,
fn fidl_into_native(self) -> Box<N>
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more