pub struct EmptyBuf;
Expand description
An empty buffer.
An EmptyBuf
is a buffer with 0 bytes of length or capacity. It implements
all of the buffer traits (XxxBuffer
and XxxBufferMut
) and both buffer
view traits (BufferView
and BufferViewMut
).
Trait Implementations§
Source§impl Buffer for EmptyBuf
impl Buffer for EmptyBuf
Source§fn parse_with_view<'a, ParseArgs, P: ParsablePacket<&'a [u8], ParseArgs>>(
&'a mut self,
args: ParseArgs,
) -> Result<(P, &'a [u8]), P::Error>
fn parse_with_view<'a, ParseArgs, P: ParsablePacket<&'a [u8], ParseArgs>>( &'a mut self, args: ParseArgs, ) -> Result<(P, &'a [u8]), P::Error>
Like
ParseBuffer::parse_with
but additionally provides an
un-structured view into the parsed data on successful parsing.Source§impl<'a> BufferView<&'a [u8]> for EmptyBuf
impl<'a> BufferView<&'a [u8]> for EmptyBuf
Source§fn take_front(&mut self, n: usize) -> Option<&'a [u8]>
fn take_front(&mut self, n: usize) -> Option<&'a [u8]>
Takes
n
bytes from the front of the buffer’s body. Read moreSource§fn take_back(&mut self, n: usize) -> Option<&'a [u8]>
fn take_back(&mut self, n: usize) -> Option<&'a [u8]>
Takes
n
bytes from the back of the buffer’s body. Read moreSource§fn into_rest(self) -> &'a [u8] ⓘ
fn into_rest(self) -> &'a [u8] ⓘ
Converts this view into a reference to the buffer’s body. Read more
Source§fn take_rest_front(&mut self) -> B
fn take_rest_front(&mut self) -> B
Takes the rest of the buffer’s body from the front. Read more
Source§fn take_rest_back(&mut self) -> B
fn take_rest_back(&mut self) -> B
Takes the rest of the buffer’s body from the back. Read more
Source§fn take_byte_front(&mut self) -> Option<u8>
fn take_byte_front(&mut self) -> Option<u8>
Takes a single byte of the buffer’s body from the front. Read more
Source§fn take_byte_back(&mut self) -> Option<u8>
fn take_byte_back(&mut self) -> Option<u8>
Takes a single byte of the buffer’s body from the back. Read more
Source§fn peek_obj_front<T>(&mut self) -> Option<&T>where
T: FromBytes + KnownLayout + Immutable + Unaligned,
fn peek_obj_front<T>(&mut self) -> Option<&T>where
T: FromBytes + KnownLayout + Immutable + Unaligned,
Peeks at an object at the front of the buffer’s body. Read more
Source§fn take_obj_front<T>(&mut self) -> Option<Ref<B, T>>where
T: KnownLayout + Immutable + Unaligned,
fn take_obj_front<T>(&mut self) -> Option<Ref<B, T>>where
T: KnownLayout + Immutable + Unaligned,
Takes an object from the front of the buffer’s body. Read more
Source§fn take_slice_front<T>(&mut self, n: usize) -> Option<Ref<B, [T]>>where
T: Immutable + Unaligned,
fn take_slice_front<T>(&mut self, n: usize) -> Option<Ref<B, [T]>>where
T: Immutable + Unaligned,
Takes a slice of objects from the front of the buffer’s body. Read more
Source§fn peek_obj_back<T>(&mut self) -> Option<&T>where
T: FromBytes + KnownLayout + Immutable + Unaligned,
fn peek_obj_back<T>(&mut self) -> Option<&T>where
T: FromBytes + KnownLayout + Immutable + Unaligned,
Peeks at an object at the back of the buffer’s body. Read more
Source§fn take_obj_back<T>(&mut self) -> Option<Ref<B, T>>where
T: Immutable + KnownLayout + Unaligned,
fn take_obj_back<T>(&mut self) -> Option<Ref<B, T>>where
T: Immutable + KnownLayout + Unaligned,
Takes an object from the back of the buffer’s body. Read more
Source§impl<'a> BufferView<&'a mut [u8]> for EmptyBuf
impl<'a> BufferView<&'a mut [u8]> for EmptyBuf
Source§fn take_front(&mut self, n: usize) -> Option<&'a mut [u8]>
fn take_front(&mut self, n: usize) -> Option<&'a mut [u8]>
Takes
n
bytes from the front of the buffer’s body. Read moreSource§fn take_back(&mut self, n: usize) -> Option<&'a mut [u8]>
fn take_back(&mut self, n: usize) -> Option<&'a mut [u8]>
Takes
n
bytes from the back of the buffer’s body. Read moreSource§fn into_rest(self) -> &'a mut [u8] ⓘ
fn into_rest(self) -> &'a mut [u8] ⓘ
Converts this view into a reference to the buffer’s body. Read more
Source§fn take_rest_front(&mut self) -> B
fn take_rest_front(&mut self) -> B
Takes the rest of the buffer’s body from the front. Read more
Source§fn take_rest_back(&mut self) -> B
fn take_rest_back(&mut self) -> B
Takes the rest of the buffer’s body from the back. Read more
Source§fn take_byte_front(&mut self) -> Option<u8>
fn take_byte_front(&mut self) -> Option<u8>
Takes a single byte of the buffer’s body from the front. Read more
Source§fn take_byte_back(&mut self) -> Option<u8>
fn take_byte_back(&mut self) -> Option<u8>
Takes a single byte of the buffer’s body from the back. Read more
Source§fn peek_obj_front<T>(&mut self) -> Option<&T>where
T: FromBytes + KnownLayout + Immutable + Unaligned,
fn peek_obj_front<T>(&mut self) -> Option<&T>where
T: FromBytes + KnownLayout + Immutable + Unaligned,
Peeks at an object at the front of the buffer’s body. Read more
Source§fn take_obj_front<T>(&mut self) -> Option<Ref<B, T>>where
T: KnownLayout + Immutable + Unaligned,
fn take_obj_front<T>(&mut self) -> Option<Ref<B, T>>where
T: KnownLayout + Immutable + Unaligned,
Takes an object from the front of the buffer’s body. Read more
Source§fn take_slice_front<T>(&mut self, n: usize) -> Option<Ref<B, [T]>>where
T: Immutable + Unaligned,
fn take_slice_front<T>(&mut self, n: usize) -> Option<Ref<B, [T]>>where
T: Immutable + Unaligned,
Takes a slice of objects from the front of the buffer’s body. Read more
Source§fn peek_obj_back<T>(&mut self) -> Option<&T>where
T: FromBytes + KnownLayout + Immutable + Unaligned,
fn peek_obj_back<T>(&mut self) -> Option<&T>where
T: FromBytes + KnownLayout + Immutable + Unaligned,
Peeks at an object at the back of the buffer’s body. Read more
Source§fn take_obj_back<T>(&mut self) -> Option<Ref<B, T>>where
T: Immutable + KnownLayout + Unaligned,
fn take_obj_back<T>(&mut self) -> Option<Ref<B, T>>where
T: Immutable + KnownLayout + Unaligned,
Takes an object from the back of the buffer’s body. Read more
Source§impl<'a> BufferViewMut<&'a mut [u8]> for EmptyBuf
impl<'a> BufferViewMut<&'a mut [u8]> for EmptyBuf
Source§fn take_front_zero(&mut self, n: usize) -> Option<B>
fn take_front_zero(&mut self, n: usize) -> Option<B>
Takes
n
bytes from the front of the buffer’s body and zeroes them. Read moreSource§fn take_back_zero(&mut self, n: usize) -> Option<B>
fn take_back_zero(&mut self, n: usize) -> Option<B>
Takes
n
bytes from the back of the buffer’s body and zeroes them. Read moreSource§fn take_rest_front_zero(self) -> B
fn take_rest_front_zero(self) -> B
Takes the rest of the buffer’s body from the front and zeroes it. Read more
Source§fn take_rest_back_zero(self) -> B
fn take_rest_back_zero(self) -> B
Takes the rest of the buffer’s body from the back and zeroes it. Read more
Source§fn into_rest_zero(self) -> B
fn into_rest_zero(self) -> B
Converts this view into a reference to the buffer’s body, and zeroes it. Read more
Source§fn take_obj_front_zero<T>(&mut self) -> Option<Ref<B, T>>where
T: KnownLayout + Immutable + Unaligned,
fn take_obj_front_zero<T>(&mut self) -> Option<Ref<B, T>>where
T: KnownLayout + Immutable + Unaligned,
Takes an object from the front of the buffer’s body and zeroes it. Read more
Source§fn take_obj_back_zero<T>(&mut self) -> Option<Ref<B, T>>where
T: KnownLayout + Immutable + Unaligned,
fn take_obj_back_zero<T>(&mut self) -> Option<Ref<B, T>>where
T: KnownLayout + Immutable + Unaligned,
Takes an object from the back of the buffer’s body and zeroes it. Read more
Source§impl FragmentedBuffer for EmptyBuf
impl FragmentedBuffer for EmptyBuf
Source§fn with_bytes<R, F>(&self, f: F) -> Rwhere
F: for<'macro_a, 'macro_b> FnOnce(FragmentedBytes<'macro_a, 'macro_b>) -> R,
fn with_bytes<R, F>(&self, f: F) -> Rwhere
F: for<'macro_a, 'macro_b> FnOnce(FragmentedBytes<'macro_a, 'macro_b>) -> R,
Invokes a callback on a view into this buffer’s contents as
FragmentedBytes
.Source§impl FragmentedBufferMut for EmptyBuf
impl FragmentedBufferMut for EmptyBuf
Source§fn with_bytes_mut<R, F>(&mut self, f: F) -> Rwhere
F: for<'macro_a, 'macro_b> FnOnce(FragmentedBytesMut<'macro_a, 'macro_b>) -> R,
fn with_bytes_mut<R, F>(&mut self, f: F) -> Rwhere
F: for<'macro_a, 'macro_b> FnOnce(FragmentedBytesMut<'macro_a, 'macro_b>) -> R,
Invokes a callback on a mutable view into this buffer’s contents as
FragmentedBytesMut
.Source§fn zero_range<R>(&mut self, range: R)where
R: RangeBounds<usize>,
fn zero_range<R>(&mut self, range: R)where
R: RangeBounds<usize>,
Sets all bytes in
range
to zero. Read moreSource§fn copy_within<R: RangeBounds<usize>>(&mut self, src: R, dest: usize)
fn copy_within<R: RangeBounds<usize>>(&mut self, src: R, dest: usize)
Copies elements from one part of the
FragmentedBufferMut
to another
part of itself. Read moreSource§impl GrowBuffer for EmptyBuf
impl GrowBuffer for EmptyBuf
Source§fn with_parts<O, F>(&self, f: F) -> O
fn with_parts<O, F>(&self, f: F) -> O
Gets a view into the parts of this
GrowBuffer
. Read moreSource§fn grow_front(&mut self, n: usize)
fn grow_front(&mut self, n: usize)
Grows the front of the body towards Growf the buffer. Read more
Source§fn grow_back(&mut self, n: usize)
fn grow_back(&mut self, n: usize)
Grows the back of the body towards the end of the buffer. Read more
Source§fn prefix_len(&self) -> usize
fn prefix_len(&self) -> usize
The length of the prefix.
Source§fn suffix_len(&self) -> usize
fn suffix_len(&self) -> usize
The length of the suffix.
Source§fn undo_parse(&mut self, meta: ParseMetadata)
fn undo_parse(&mut self, meta: ParseMetadata)
Undoes the effects of a previous parse in preparation for serialization. Read more
Source§impl GrowBufferMut for EmptyBuf
impl GrowBufferMut for EmptyBuf
Source§fn with_parts_mut<O, F>(&mut self, f: F) -> O
fn with_parts_mut<O, F>(&mut self, f: F) -> O
Gets a mutable view into the parts of this
GrowBufferMut
. Read moreSource§fn grow_front_zero(&mut self, n: usize)
fn grow_front_zero(&mut self, n: usize)
Extends the front of the body towards the beginning of the buffer,
zeroing the new bytes. Read more
Source§fn grow_back_zero(&mut self, n: usize)
fn grow_back_zero(&mut self, n: usize)
Extends the back of the body towards the end of the buffer, zeroing the
new bytes. Read more
Source§fn reset_zero(&mut self)
fn reset_zero(&mut self)
Resets the body to be equal to the entire buffer, zeroing the new bytes. Read more
Source§impl ParseBuffer for EmptyBuf
impl ParseBuffer for EmptyBuf
Source§fn parse_with<'a, ParseArgs, P: ParsablePacket<&'a [u8], ParseArgs>>(
&'a mut self,
args: ParseArgs,
) -> Result<P, P::Error>
fn parse_with<'a, ParseArgs, P: ParsablePacket<&'a [u8], ParseArgs>>( &'a mut self, args: ParseArgs, ) -> Result<P, P::Error>
Parses a packet with arguments. Read more
Source§impl ParseBufferMut for EmptyBuf
impl ParseBufferMut for EmptyBuf
Source§fn parse_with_mut<'a, ParseArgs, P: ParsablePacket<&'a mut [u8], ParseArgs>>(
&'a mut self,
args: ParseArgs,
) -> Result<P, P::Error>
fn parse_with_mut<'a, ParseArgs, P: ParsablePacket<&'a mut [u8], ParseArgs>>( &'a mut self, args: ParseArgs, ) -> Result<P, P::Error>
Parses a mutable packet with arguments. Read more
Source§impl ShrinkBuffer for EmptyBuf
impl ShrinkBuffer for EmptyBuf
Source§fn shrink_front(&mut self, n: usize)
fn shrink_front(&mut self, n: usize)
Shrinks the front of the body towards the end of the buffer. Read more
Source§fn shrink_back(&mut self, n: usize)
fn shrink_back(&mut self, n: usize)
Shrinks the back of the body towards the beginning of the buffer. Read more
Source§fn shrink_front_to(&mut self, len: usize)
fn shrink_front_to(&mut self, len: usize)
Shrinks the buffer to be no larger than
len
bytes, consuming from the
front. Read moreSource§fn shrink_back_to(&mut self, len: usize)
fn shrink_back_to(&mut self, len: usize)
Shrinks the buffer to be no larger than
len
bytes, consuming from the
back. Read moreimpl ContiguousBuffer for EmptyBuf
impl Copy for EmptyBuf
impl Eq for EmptyBuf
impl StructuralPartialEq for EmptyBuf
Auto Trait Implementations§
impl Freeze for EmptyBuf
impl RefUnwindSafe for EmptyBuf
impl Send for EmptyBuf
impl Sync for EmptyBuf
impl Unpin for EmptyBuf
impl UnwindSafe for EmptyBuf
Blanket Implementations§
Source§impl<O, B> AsFragmentedByteSlice<B> for O
impl<O, B> AsFragmentedByteSlice<B> for O
Source§fn as_fragmented_byte_slice(&mut self) -> FragmentedByteSlice<'_, B>
fn as_fragmented_byte_slice(&mut self) -> FragmentedByteSlice<'_, B>
Generates a
FragmentedByteSlice
view of self
.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
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§unsafe fn clone_to_uninit(&self, dst: *mut T)
unsafe fn clone_to_uninit(&self, dst: *mut T)
🔬This is a nightly-only experimental API. (
clone_to_uninit
)Source§impl<B> Serializer for Bwhere
B: GrowBuffer + ShrinkBuffer,
impl<B> Serializer for Bwhere
B: GrowBuffer + ShrinkBuffer,
Source§fn serialize<BB, P>(
self,
outer: PacketConstraints,
provider: P,
) -> Result<BB, (SerializeError<<P as BufferProvider<<B as Serializer>::Buffer, BB>>::Error>, B)>
fn serialize<BB, P>( self, outer: PacketConstraints, provider: P, ) -> Result<BB, (SerializeError<<P as BufferProvider<<B as Serializer>::Buffer, BB>>::Error>, B)>
Serializes this
Serializer
, producing a buffer. Read moreSource§fn serialize_new_buf<BB, A>(
&self,
outer: PacketConstraints,
alloc: A,
) -> Result<BB, SerializeError<<A as BufferAlloc<BB>>::Error>>where
BB: ReusableBuffer,
A: BufferAlloc<BB>,
fn serialize_new_buf<BB, A>(
&self,
outer: PacketConstraints,
alloc: A,
) -> Result<BB, SerializeError<<A as BufferAlloc<BB>>::Error>>where
BB: ReusableBuffer,
A: BufferAlloc<BB>,
Serializes the data into a new buffer without consuming
self
. Read moreSource§fn serialize_vec(
self,
outer: PacketConstraints,
) -> Result<Either<Self::Buffer, Buf<Vec<u8>>>, (SerializeError<Never>, Self)>where
Self::Buffer: ReusableBuffer,
fn serialize_vec(
self,
outer: PacketConstraints,
) -> Result<Either<Self::Buffer, Buf<Vec<u8>>>, (SerializeError<Never>, Self)>where
Self::Buffer: ReusableBuffer,
Serializes this
Serializer
, allocating a Buf<Vec<u8>>
if the
contained buffer isn’t large enough. Read moreSource§fn serialize_no_alloc(
self,
outer: PacketConstraints,
) -> Result<Self::Buffer, (SerializeError<BufferTooShortError>, Self)>where
Self::Buffer: ReusableBuffer,
fn serialize_no_alloc(
self,
outer: PacketConstraints,
) -> Result<Self::Buffer, (SerializeError<BufferTooShortError>, Self)>where
Self::Buffer: ReusableBuffer,
Serializes this
Serializer
, failing if the existing buffer is not
large enough. Read moreSource§fn serialize_outer<B: GrowBufferMut, P: BufferProvider<Self::Buffer, B>>(
self,
provider: P,
) -> Result<B, (SerializeError<P::Error>, Self)>
fn serialize_outer<B: GrowBufferMut, P: BufferProvider<Self::Buffer, B>>( self, provider: P, ) -> Result<B, (SerializeError<P::Error>, Self)>
Serializes this
Serializer
as the outermost packet. Read moreSource§fn serialize_vec_outer(
self,
) -> Result<Either<Self::Buffer, Buf<Vec<u8>>>, (SerializeError<Never>, Self)>where
Self::Buffer: ReusableBuffer,
fn serialize_vec_outer(
self,
) -> Result<Either<Self::Buffer, Buf<Vec<u8>>>, (SerializeError<Never>, Self)>where
Self::Buffer: ReusableBuffer,
Serializes this
Serializer
as the outermost packet, allocating a
Buf<Vec<u8>>
if the contained buffer isn’t large enough. Read moreSource§fn serialize_no_alloc_outer(
self,
) -> Result<Self::Buffer, (SerializeError<BufferTooShortError>, Self)>where
Self::Buffer: ReusableBuffer,
fn serialize_no_alloc_outer(
self,
) -> Result<Self::Buffer, (SerializeError<BufferTooShortError>, Self)>where
Self::Buffer: ReusableBuffer,
Serializes this
Serializer
as the outermost packet, failing if the
existing buffer is not large enough. Read moreSource§fn encapsulate<B>(self, outer: B) -> Nested<Self, B>
fn encapsulate<B>(self, outer: B) -> Nested<Self, B>
Source§fn with_size_limit(self, limit: usize) -> Nested<Self, LimitedSizePacketBuilder>
fn with_size_limit(self, limit: usize) -> Nested<Self, LimitedSizePacketBuilder>
Creates a new
Serializer
which will enforce a size limit. Read more