RepeatedView

Struct RepeatedView 

Source
pub struct RepeatedView<B, T: HasView<B> + NextLayer> { /* private fields */ }
Expand description

A borrowed block of headers whose elements are parsed identically (i.e., using the same choice or Ingot type), and may be chained using hint values.

Implementations§

Source§

impl<B: ByteSlice, T: for<'a> HasView<&'a [u8]> + HasView<B> + NextLayer> RepeatedView<B, T>

Source

pub fn iter(&self, hint: Option<T::Hint>) -> RepeatedViewIter<'_, T>

Iterates over all sub-parsed elements.

Offsets are not stored, so individual elements are re-parsed one by one.

Trait Implementations§

Source§

impl<B: ByteSliceMut, T: HasView<B> + NextLayer> AsMut<[u8]> for RepeatedView<B, T>

Source§

fn as_mut(&mut self) -> &mut [u8]

Converts this type into a mutable reference of the (usually inferred) input type.
Source§

impl<B: ByteSlice, T: HasView<B> + NextLayer> AsRef<[u8]> for RepeatedView<B, T>

Source§

fn as_ref(&self) -> &[u8]

Converts this type into a shared reference of the (usually inferred) input type.
Source§

impl<B: ByteSlice, T: HeaderLen + NextLayer + HasView<B>> Emit for RepeatedView<B, T>

Source§

fn emit_raw<V: ByteSliceMut>(&self, buf: V) -> usize

Writes this packet’s contents into a target buffer without performing length checks. Read more
Source§

fn needs_emit(&self) -> bool

Returns whether this packet needs a full re-emit, and has not been simply modified in-place. Read more
Source§

fn emit<V: ByteSliceMut>(&self, buf: V) -> ParseResult<usize>

Writes this packet’s contents into a target buffer.
Source§

fn emit_prefix<V: SplitByteSliceMut>(&self, buf: V) -> ParseResult<V>

Writes this packet’s contents into the start of a target buffer.
Source§

fn emit_suffix<V: SplitByteSliceMut>(&self, buf: V) -> ParseResult<V>

Writes this packet’s contents at the end of a target buffer.
Source§

fn to_vec(&self) -> Vec<u8>

Writes this packet’s contents into a newly allocated Vec of length Header::packet_length. Read more
Source§

impl<B: ByteSlice, T: HeaderLen + NextLayer + HasView<B>> HeaderLen for RepeatedView<B, T>

Source§

const MINIMUM_LENGTH: usize = 0usize

The minimum number of bytes a packet of this kind occupies when serialised.
Source§

fn packet_length(&self) -> usize

The number of bytes which this packet would occupy when serialised. Read more
Source§

impl<B: SplitByteSlice, T> HeaderParse<B> for RepeatedView<B, T>
where T: for<'a> HasView<&'a [u8]> + HasView<B> + NextLayer<Hint = <T as NextLayer>::Denom>, for<'a> <T as HasView<&'a [u8]>>::ViewType: HeaderParse<&'a [u8]> + NextLayer<Denom = T::Denom, Hint = T::Hint>,

Source§

fn parse_choice(data: B, hint: Option<T::Hint>) -> ParseResult<Success<Self, B>>

Parse a view-type from a given buffer, using a hint
Source§

fn parse(from: B) -> ParseResult<Success<Self, B>>

Parse a view-type from a given buffer.
Source§

impl<B: ByteSlice, T: for<'a> HasView<&'a [u8]> + HasView<B> + NextLayer<Hint = <T as NextLayer>::Denom>> NextLayer for RepeatedView<B, T>
where for<'a> <T as HasView<&'a [u8]>>::ViewType: HeaderParse<&'a [u8]> + NextLayer<Denom = T::Denom, Hint = T::Hint>,

Source§

type Denom = <T as NextLayer>::Denom

The type of this header’s next-layer hint.
Source§

type Hint = <T as NextLayer>::Hint

A type used to help parse the header
Source§

fn next_layer_choice(&self, hint: Option<Self::Hint>) -> Option<Self::Denom>

Try to retrieve this header’s next-layer hint, using a provided hint
Source§

fn next_layer(&self) -> Option<Self::Denom>

Retrieve this header’s next-layer hint, if possible.
Source§

impl<B: SplitByteSlice, T, E> ToOwnedPacket for RepeatedView<B, T>
where T: for<'a> HasView<&'a [u8]> + NextLayer<Hint = <T as NextLayer>::Denom> + HasView<B>, for<'a> <T as HasView<&'a [u8]>>::ViewType: HeaderParse<&'a [u8]> + NextLayer<Denom = T::Denom, Hint = T::Hint>, for<'a, 'b> &'b <T as HasView<&'a [u8]>>::ViewType: TryInto<T, Error = E>, ParseError: From<E>,

Source§

type Target = Repeated<T>

The output type of this conversion.
Source§

fn to_owned(&self, hint: Option<T::Hint>) -> ParseResult<Self::Target>

Converts a borrowed view of a header into an owned version, possibly reparsing to do so with the aid of hint.

Auto Trait Implementations§

§

impl<B, T> Freeze for RepeatedView<B, T>
where B: Freeze,

§

impl<B, T> RefUnwindSafe for RepeatedView<B, T>

§

impl<B, T> Send for RepeatedView<B, T>
where B: Send, T: Send,

§

impl<B, T> Sync for RepeatedView<B, T>
where B: Sync, T: Sync,

§

impl<B, T> Unpin for RepeatedView<B, T>
where B: Unpin, T: Unpin,

§

impl<B, T> UnwindSafe for RepeatedView<B, T>
where B: UnwindSafe, T: 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> 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, 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.