Trait RangeExt

Source
pub trait RangeExt<T> {
    // Required methods
    fn is_valid(&self) -> bool;
    fn length(&self) -> Result<T, Error>;
    fn is_aligned(&self, block_size: impl Into<T>) -> bool;
    fn split(self, split_point: T) -> (Option<Range<T>>, Option<Range<T>>);
}

Required Methods§

Source

fn is_valid(&self) -> bool

Returns whether the range is valid (i.e. start <= end).

Source

fn length(&self) -> Result<T, Error>

Returns the length of the range, or an error if the range is !RangeExt::is_valid(). Since this is intended to be used primarily for possibly-untrusted serialized ranges, the error returned is FxfsError::Inconsistent.

Source

fn is_aligned(&self, block_size: impl Into<T>) -> bool

Returns true if the range is aligned to the given block size.

Source

fn split(self, split_point: T) -> (Option<Range<T>>, Option<Range<T>>)

Splits the half-open range [range.start, range.end) into the ranges [range.start, split_point) and [split_point, range.end). If either of the new ranges would be empty, then None is returned in its place and Some(range) is returned for the other. range must not be empty.

Dyn Compatibility§

This trait is not dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.

Implementations on Foreign Types§

Source§

impl<T: Sub<Output = T> + Copy + Ord + Debug + Rem<Output = T> + PartialEq + Default> RangeExt<T> for Range<T>

Source§

fn is_valid(&self) -> bool

Source§

fn length(&self) -> Result<T, Error>

Source§

fn is_aligned(&self, block_size: impl Into<T>) -> bool

Source§

fn split(self, split_point: T) -> (Option<Range<T>>, Option<Range<T>>)

Implementors§