Skip to main content

NonEmptyRange

Struct NonEmptyRange 

Source
pub struct NonEmptyRange<Idx>(/* private fields */);
Expand description

A non-empty Range (start..end) where start < end is guaranteed.

Implementations§

Source§

impl<Idx: PartialOrd> NonEmptyRange<Idx>

Source

pub fn new(range: Range<Idx>) -> Result<Self, EmptyRange>

Creates a NonEmptyRange if start < end.

Source§

impl<Idx: Copy> NonEmptyRange<Idx>

Source

pub const fn start(&self) -> Idx

Returns the start of the range.

Source

pub const fn end(&self) -> Idx

Returns the end of the range (exclusive).

Trait Implementations§

Source§

impl<Idx: Clone> Clone for NonEmptyRange<Idx>

Source§

fn clone(&self) -> NonEmptyRange<Idx>

Returns a duplicate of the value. Read more
1.0.0 · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl<Idx: Debug> Debug for NonEmptyRange<Idx>

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl<Idx: EncodeSize> EncodeSize for NonEmptyRange<Idx>

Source§

fn encode_size(&self) -> usize

Returns the encoded size of this value (in bytes).
Source§

fn encode_inline_size(&self) -> usize

Returns the encoded size excluding bytes passed to BufsMut::push during Write::write_bufs. Used to size the working buffer for inline writes. Override alongside Write::write_bufs for types where large Bytes fields go via push; failing to do so will over-allocate.
Source§

impl<Idx> From<NonEmptyRange<Idx>> for Range<Idx>

Source§

fn from(r: NonEmptyRange<Idx>) -> Self

Converts to this type from the input type.
Source§

impl<Idx: Hash> Hash for NonEmptyRange<Idx>

Source§

fn hash<__H: Hasher>(&self, state: &mut __H)

Feeds this value into the given Hasher. Read more
1.3.0 · Source§

fn hash_slice<H>(data: &[Self], state: &mut H)
where H: Hasher, Self: Sized,

Feeds a slice of this type into the given Hasher. Read more
Source§

impl<Idx> IntoIterator for NonEmptyRange<Idx>
where Range<Idx>: Iterator,

Source§

type Item = <Range<Idx> as Iterator>::Item

The type of the elements being iterated over.
Source§

type IntoIter = Range<Idx>

Which kind of iterator are we turning this into?
Source§

fn into_iter(self) -> Self::IntoIter

Creates an iterator from a value. Read more
Source§

impl<Idx: PartialEq> PartialEq for NonEmptyRange<Idx>

Source§

fn eq(&self, other: &NonEmptyRange<Idx>) -> bool

Tests for self and other values to be equal, and is used by ==.
1.0.0 · Source§

fn ne(&self, other: &Rhs) -> bool

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
Source§

impl<Idx: Read + PartialOrd> Read for NonEmptyRange<Idx>

Source§

type Cfg = <Idx as Read>::Cfg

The Cfg type parameter allows passing configuration during the read process. This is crucial for safely decoding untrusted data, for example, by providing size limits for collections or strings. Read more
Source§

fn read_cfg(buf: &mut impl Buf, cfg: &Self::Cfg) -> Result<Self, CodecError>

Reads a value from the buffer using the provided configuration cfg. Read more
Source§

impl<Idx: PartialOrd> TryFrom<Range<Idx>> for NonEmptyRange<Idx>

Source§

type Error = EmptyRange

The type returned in the event of a conversion error.
Source§

fn try_from(range: Range<Idx>) -> Result<Self, Self::Error>

Performs the conversion.
Source§

impl<Idx: Write + PartialOrd> Write for NonEmptyRange<Idx>

Source§

fn write(&self, buf: &mut impl BufMut)

Writes the binary representation of self to the provided buffer buf. Read more
Source§

fn write_bufs(&self, buf: &mut impl BufsMut)

Writes to a BufsMut, allowing existing Bytes chunks to be appended via BufsMut::push instead of written inline. Must encode to the same format as Write::write. Defaults to Write::write.
Source§

impl<Idx: Eq> Eq for NonEmptyRange<Idx>

Source§

impl<Idx> StructuralPartialEq for NonEmptyRange<Idx>

Auto Trait Implementations§

§

impl<Idx> Freeze for NonEmptyRange<Idx>
where Idx: Freeze,

§

impl<Idx> RefUnwindSafe for NonEmptyRange<Idx>
where Idx: RefUnwindSafe,

§

impl<Idx> Send for NonEmptyRange<Idx>
where Idx: Send,

§

impl<Idx> Sync for NonEmptyRange<Idx>
where Idx: Sync,

§

impl<Idx> Unpin for NonEmptyRange<Idx>
where Idx: Unpin,

§

impl<Idx> UnsafeUnpin for NonEmptyRange<Idx>
where Idx: UnsafeUnpin,

§

impl<Idx> UnwindSafe for NonEmptyRange<Idx>
where Idx: UnwindSafe,

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> Decode for T
where T: Read,

Source§

fn decode_cfg(buf: impl Buf, cfg: &Self::Cfg) -> Result<Self, Error>

Decodes a value from buf using cfg, ensuring the entire buffer is consumed. Read more
Source§

impl<X, T> DecodeExt<X> for T
where X: IsUnit, T: Decode<Cfg = X>,

Source§

fn decode(buf: impl Buf) -> Result<Self, Error>

Decodes a value using the default () config.
Source§

impl<X, U> DecodeRangeExt<X> for U
where X: IsUnit, U: Decode<Cfg = (RangeCfg<usize>, X)>,

Source§

fn decode_range( buf: impl Buf, range: impl RangeBounds<usize>, ) -> Result<Self, Error>

Decodes a value using only a range configuration. Read more
Source§

impl<T> Encode for T
where T: Write + EncodeSize,

Source§

fn encode(&self) -> Bytes

Encodes self into a new Bytes buffer. Read more
Source§

fn encode_mut(&self) -> BytesMut

Encodes self into a new BytesMut buffer. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> ReadExt for T
where T: Read<Cfg = ()>,

Source§

fn read(buf: &mut impl Buf) -> Result<Self, Error>

Reads a value using the default () config.
Source§

impl<X, U> ReadRangeExt<X> for U
where X: IsUnit, U: Read<Cfg = (RangeCfg<usize>, X)>,

Source§

fn read_range( buf: &mut impl Buf, range: impl RangeBounds<usize>, ) -> Result<Self, Error>

Reads a value using only a range configuration. Read more
Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

Source§

fn vzip(self) -> V

Source§

impl<T> Codec for T
where T: Encode + Decode,

Source§

impl<T> CodecShared for T
where T: Codec + Send + Sync,

Source§

impl<T> EncodeShared for T
where T: Encode + Send + Sync,