FieldRef

Enum FieldRef 

Source
pub enum FieldRef<'a, T: HasView<V>, V> {
    Repr(&'a T),
    Raw(&'a <T as HasView<V>>::ViewType),
}
Expand description

An equivalent to Header for header fields which are accessed by shared reference.

Variants§

§

Repr(&'a T)

Reference to the owned representation of a field.

§

Raw(&'a <T as HasView<V>>::ViewType)

Reference to a field in a borrowed header, which may be owned or borrowed depdendent on past modifications.

Implementations§

Source§

impl<B: ByteSlice> FieldRef<'_, Vec<u8>, B>

Source

pub fn to_owned(&self) -> Vec<u8>

Copy this field out into a list of its raw bytes.

Trait Implementations§

Source§

impl<Z, T: HasView<V, ViewType = Q> + AsRef<[Z]>, V, Q: AsRef<[Z]>> AsRef<[Z]> for FieldRef<'_, T, V>

Source§

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

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

impl<'a, T: HasView<V>, V> From<&'a BoxedHeader<T, <T as HasView<V>>::ViewType>> for FieldRef<'a, T, V>

Available on crate feature alloc only.
Source§

fn from(value: &'a BoxedHeader<T, <T as HasView<V>>::ViewType>) -> Self

Converts to this type from the input type.
Source§

impl<'a, T: HasView<V>, V> From<&'a InlineHeader<T, <T as HasView<V>>::ViewType>> for FieldRef<'a, T, V>

Source§

fn from(value: &'a InlineHeader<T, <T as HasView<V>>::ViewType>) -> Self

Converts to this type from the input type.
Source§

impl<T: HeaderLen + HasView<V>, V> HeaderLen for FieldRef<'_, T, V>
where T::ViewType: HeaderLen,

Source§

const MINIMUM_LENGTH: usize = T::MINIMUM_LENGTH

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<T: HasView<V, ViewType = Q> + NextLayer, V, Q> NextLayer for FieldRef<'_, T, V>
where <T as HasView<V>>::ViewType: 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.

Auto Trait Implementations§

§

impl<'a, T, V> Freeze for FieldRef<'a, T, V>

§

impl<'a, T, V> RefUnwindSafe for FieldRef<'a, T, V>

§

impl<'a, T, V> Send for FieldRef<'a, T, V>
where T: Sync, <T as HasView<V>>::ViewType: Sync,

§

impl<'a, T, V> Sync for FieldRef<'a, T, V>
where T: Sync, <T as HasView<V>>::ViewType: Sync,

§

impl<'a, T, V> Unpin for FieldRef<'a, T, V>

§

impl<'a, T, V> UnwindSafe for FieldRef<'a, T, V>

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.