octseq::octets

Trait Octets

source
pub trait Octets: AsRef<[u8]> {
    type Range<'a>: Octets
       where Self: 'a;

    // Required method
    fn range(&self, range: impl RangeBounds<usize>) -> Self::Range<'_>;
}
Expand description

A type representing an octets sequence.

The primary purpose of the trait is to allow access to a sub-sequence, called a ‘range.’ The type of this range is given via the Range associated type. For most types it will be a &[u8] with a lifetime equal to that of a reference. Only if an owned range can be created cheaply, it should be that type.

Required Associated Types§

source

type Range<'a>: Octets where Self: 'a

Required Methods§

source

fn range(&self, range: impl RangeBounds<usize>) -> Self::Range<'_>

Returns a sub-sequence or ‘range’ of the sequence.

§Panics

The method should panic if start or end are greater than the length of the octets sequence or if start is greater than end.

Object Safety§

This trait is not object safe.

Implementations on Foreign Types§

source§

impl Octets for Bytes

source§

type Range<'a> = Bytes

source§

fn range(&self, range: impl RangeBounds<usize>) -> Self::Range<'_>

source§

impl Octets for Arc<[u8]>

source§

type Range<'a> = &'a [u8]

source§

fn range(&self, range: impl RangeBounds<usize>) -> Self::Range<'_>

source§

impl Octets for Vec<u8>

source§

type Range<'a> = &'a [u8]

source§

fn range(&self, range: impl RangeBounds<usize>) -> Self::Range<'_>

source§

impl Octets for [u8]

source§

type Range<'a> = &'a [u8]

source§

fn range(&self, range: impl RangeBounds<usize>) -> Self::Range<'_>

source§

impl<'c> Octets for Cow<'c, [u8]>

source§

type Range<'a> = &'a [u8] where Self: 'a

source§

fn range(&self, range: impl RangeBounds<usize>) -> Self::Range<'_>

source§

impl<'t, T: Octets + ?Sized> Octets for &'t T

source§

type Range<'a> = <T as Octets>::Range<'t> where Self: 'a

source§

fn range(&self, range: impl RangeBounds<usize>) -> Self::Range<'_>

source§

impl<A: Array<Item = u8>> Octets for SmallVec<A>

source§

type Range<'a> = &'a [u8] where A: 'a

source§

fn range(&self, range: impl RangeBounds<usize>) -> Self::Range<'_>

Implementors§

source§

impl<const N: usize> Octets for Array<N>

source§

type Range<'a> = &'a [u8]