pub enum BoxedHeader<O, B> {
Repr(Box<O>),
Raw(B),
}Expand description
A header which is either owned or read from a buffer, which heap-allocates if the data is owned.
Generally, use of boxed Repr values reduces output struct sizes
when parsing full packets and is preferred when compiling with the
alloc feature. See InlineHeader if stack allocation is needed.
Variants§
Repr(Box<O>)
Owned, in-memory representation of a header.
Raw(B)
Packed representation of a header, read from an existing buffer.
Implementations§
Source§impl<O, B> BoxedHeader<O, B>
impl<O, B> BoxedHeader<O, B>
Sourcepub fn repr(&self) -> Option<&O>
pub fn repr(&self) -> Option<&O>
Return a reference to this packet’s contents if they are owned.
Sourcepub fn repr_mut(&mut self) -> Option<&mut O>
pub fn repr_mut(&mut self) -> Option<&mut O>
Return a mutable reference to this packet’s contents if they are owned.
Trait Implementations§
Source§impl<O: Clone, B: Clone> Clone for BoxedHeader<O, B>
impl<O: Clone, B: Clone> Clone for BoxedHeader<O, B>
Source§fn clone(&self) -> BoxedHeader<O, B>
fn clone(&self) -> BoxedHeader<O, B>
Returns a duplicate of the value. Read more
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source. Read moreSource§impl<O: Emit, B: Emit> Emit for BoxedHeader<O, B>
impl<O: Emit, B: Emit> Emit for BoxedHeader<O, B>
Source§fn emit_raw<V: ByteSliceMut>(&self, buf: V) -> usize
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
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>
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>
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>
fn emit_suffix<V: SplitByteSliceMut>(&self, buf: V) -> ParseResult<V>
Writes this packet’s contents at the end of a target buffer.
Source§fn emit_uninit(&self, buf: &mut [MaybeUninit<u8>]) -> ParseResult<usize>where
Self: EmitDoesNotRelyOnBufContents,
fn emit_uninit(&self, buf: &mut [MaybeUninit<u8>]) -> ParseResult<usize>where
Self: EmitDoesNotRelyOnBufContents,
Writes this packet’s contents into uninitialised memory.
Source§fn emit_vec(&self) -> Vec<u8>where
Self: EmitDoesNotRelyOnBufContents,
fn emit_vec(&self) -> Vec<u8>where
Self: EmitDoesNotRelyOnBufContents,
Writes this packet’s contents into a newly allocated
Vec of length
Header::packet_length, without zero-filling the contents. Read moreSource§impl<'a, T: HasView<V>, V> From<&'a BoxedHeader<T, <T as HasView<V>>::ViewType>> for FieldRef<'a, T, V>
impl<'a, T: HasView<V>, V> From<&'a BoxedHeader<T, <T as HasView<V>>::ViewType>> for FieldRef<'a, T, V>
Source§impl<B: ByteSlice, T> From<&BoxedHeader<Vec<T>, ObjectSlice<B, T>>> for Vec<T>
impl<B: ByteSlice, T> From<&BoxedHeader<Vec<T>, ObjectSlice<B, T>>> for Vec<T>
Source§impl<'a, T: HasView<V>, V> From<&'a mut BoxedHeader<T, <T as HasView<V>>::ViewType>> for FieldMut<'a, T, V>
impl<'a, T: HasView<V>, V> From<&'a mut BoxedHeader<T, <T as HasView<V>>::ViewType>> for FieldMut<'a, T, V>
Source§impl<O, B> From<BoxedHeader<O, B>> for InlineHeader<O, B>
impl<O, B> From<BoxedHeader<O, B>> for InlineHeader<O, B>
Source§fn from(value: BoxedHeader<O, B>) -> Self
fn from(value: BoxedHeader<O, B>) -> Self
Converts to this type from the input type.
Source§impl<O, B> From<InlineHeader<O, B>> for BoxedHeader<O, B>
impl<O, B> From<InlineHeader<O, B>> for BoxedHeader<O, B>
Source§fn from(value: InlineHeader<O, B>) -> Self
fn from(value: InlineHeader<O, B>) -> Self
Converts to this type from the input type.
Source§impl<O, B> HasRepr for BoxedHeader<O, B>
impl<O, B> HasRepr for BoxedHeader<O, B>
Source§impl<O: HasView<V, ViewType = B>, B, V> HasView<V> for BoxedHeader<O, B>
impl<O: HasView<V, ViewType = B>, B, V> HasView<V> for BoxedHeader<O, B>
Source§impl<O, B> HeaderLen for BoxedHeader<O, B>
impl<O, B> HeaderLen for BoxedHeader<O, B>
Source§const MINIMUM_LENGTH: usize = O::MINIMUM_LENGTH
const MINIMUM_LENGTH: usize = O::MINIMUM_LENGTH
The minimum number of bytes a packet of this kind occupies
when serialised.
Source§fn packet_length(&self) -> usize
fn packet_length(&self) -> usize
The number of bytes which this packet would occupy when serialised. Read more
Source§impl<V: SplitByteSlice, B> HeaderParse<V> for BoxedHeader<B::ReprType, B>
impl<V: SplitByteSlice, B> HeaderParse<V> for BoxedHeader<B::ReprType, B>
Source§fn parse_choice(
from: V,
hint: Option<Self::Hint>,
) -> ParseResult<Success<Self, V>>
fn parse_choice( from: V, hint: Option<Self::Hint>, ) -> ParseResult<Success<Self, V>>
Parse a view-type from a given buffer, using a hint
Source§fn parse(from: B) -> ParseResult<Success<Self, B>>
fn parse(from: B) -> ParseResult<Success<Self, B>>
Parse a view-type from a given buffer.
Source§impl<O: NextLayer, B> NextLayer for BoxedHeader<O, B>
impl<O: NextLayer, B> NextLayer for BoxedHeader<O, B>
Source§impl<O: NextLayer + Clone, B: NextLayer<Denom = O::Denom, Hint = O::Hint> + ToOwnedPacket<Target = O>> ToOwnedPacket for BoxedHeader<O, B>
impl<O: NextLayer + Clone, B: NextLayer<Denom = O::Denom, Hint = O::Hint> + ToOwnedPacket<Target = O>> ToOwnedPacket for BoxedHeader<O, B>
impl<O: EmitDoesNotRelyOnBufContents, B: EmitDoesNotRelyOnBufContents> EmitDoesNotRelyOnBufContents for BoxedHeader<O, B>
impl<O: Eq, B: Eq> Eq for BoxedHeader<O, B>
impl<O, B> StructuralPartialEq for BoxedHeader<O, B>
Auto Trait Implementations§
impl<O, B> Freeze for BoxedHeader<O, B>where
B: Freeze,
impl<O, B> RefUnwindSafe for BoxedHeader<O, B>where
B: RefUnwindSafe,
O: RefUnwindSafe,
impl<O, B> Send for BoxedHeader<O, B>
impl<O, B> Sync for BoxedHeader<O, B>
impl<O, B> Unpin for BoxedHeader<O, B>where
B: Unpin,
impl<O, B> UnwindSafe for BoxedHeader<O, B>where
B: UnwindSafe,
O: UnwindSafe,
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more