Struct packet::EmptyBuf

source ·
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 AsMut<[u8]> for EmptyBuf

source§

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

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

impl AsRef<[u8]> for EmptyBuf

source§

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

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

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>

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

source§

fn len(&self) -> usize

The length of the buffer’s body.
source§

fn take_front(&mut self, n: usize) -> Option<&'a [u8]>

Takes n bytes from the front of the buffer’s body. Read more
source§

fn take_back(&mut self, n: usize) -> Option<&'a [u8]>

Takes n bytes from the back of the buffer’s body. Read more
source§

fn into_rest(self) -> &'a [u8]

Converts this view into a reference to the buffer’s body. Read more
source§

fn is_empty(&self) -> bool

Is the buffer’s body empty?
source§

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

Takes the rest of the buffer’s body from the back. Read more
source§

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>

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 + NoCell + 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: 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: 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 + NoCell + 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: Unaligned,

Takes an object from the back of the buffer’s body. Read more
source§

fn take_slice_back<T>(&mut self, n: usize) -> Option<Ref<B, [T]>>
where T: Unaligned,

Takes a slice of objects from the back of the buffer’s body. Read more
source§

impl<'a> BufferView<&'a mut [u8]> for EmptyBuf

source§

fn len(&self) -> usize

The length of the buffer’s body.
source§

fn take_front(&mut self, n: usize) -> Option<&'a mut [u8]>

Takes n bytes from the front of the buffer’s body. Read more
source§

fn take_back(&mut self, n: usize) -> Option<&'a mut [u8]>

Takes n bytes from the back of the buffer’s body. Read more
source§

fn into_rest(self) -> &'a mut [u8]

Converts this view into a reference to the buffer’s body. Read more
source§

fn is_empty(&self) -> bool

Is the buffer’s body empty?
source§

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

Takes the rest of the buffer’s body from the back. Read more
source§

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>

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 + NoCell + 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: 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: 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 + NoCell + 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: Unaligned,

Takes an object from the back of the buffer’s body. Read more
source§

fn take_slice_back<T>(&mut self, n: usize) -> Option<Ref<B, [T]>>
where T: Unaligned,

Takes a slice of objects from the back of the buffer’s body. Read more
source§

impl<'a> BufferViewMut<&'a mut [u8]> for EmptyBuf

source§

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 more
source§

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 more
source§

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

Takes the rest of the buffer’s body from the back and zeroes it. Read more
source§

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: 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: Unaligned,

Takes an object from the back of the buffer’s body and zeroes it. Read more
source§

fn write_obj_front<T>(&mut self, obj: &T) -> Option<()>
where T: ?Sized + AsBytes + NoCell,

Writes an object to the front of the buffer’s body, consuming the bytes. Read more
source§

fn write_obj_back<T>(&mut self, obj: &T) -> Option<()>
where T: ?Sized + AsBytes + NoCell,

Writes an object to the back of the buffer’s body, consuming the bytes. Read more
source§

impl Clone for EmptyBuf

source§

fn clone(&self) -> EmptyBuf

Returns a copy of the value. Read more
1.0.0 · source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
source§

impl Debug for EmptyBuf

source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
source§

impl FragmentedBuffer for EmptyBuf

source§

fn len(&self) -> usize

Gets the total length, in bytes, of this FragmentedBuffer.
source§

fn with_bytes<R, F>(&self, f: F) -> R
where 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§

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

Returns a flattened version of this buffer, copying its contents into a Vec.
source§

fn is_empty(&self) -> bool

Returns true if this FragmentedBuffer is empty.
source§

impl FragmentedBufferMut for EmptyBuf

source§

fn with_bytes_mut<R, F>(&mut self, f: F) -> R
where 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>,

Sets all bytes in range to zero. Read more
source§

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 more
source§

fn copy_from<B: FragmentedBuffer>(&mut self, other: &B)

Copies all the bytes from another FragmentedBuffer other into self. Read more
source§

impl GrowBuffer for EmptyBuf

source§

fn with_parts<O, F>(&self, f: F) -> O
where F: for<'a, 'b> FnOnce(&'a [u8], FragmentedBytes<'a, 'b>, &'a [u8]) -> O,

Gets a view into the parts of this GrowBuffer. Read more
source§

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)

Grows the back of the body towards the end of the buffer. Read more
source§

fn capacity(&self) -> usize

The capacity of the buffer. Read more
source§

fn prefix_len(&self) -> usize

The length of the prefix.
source§

fn suffix_len(&self) -> usize

The length of the suffix.
source§

fn reset(&mut self)

Resets the body to be equal to the entire buffer. Read more
source§

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

source§

fn with_parts_mut<O, F>(&mut self, f: F) -> O
where F: for<'a, 'b> FnOnce(&'a mut [u8], FragmentedBytesMut<'a, 'b>, &'a mut [u8]) -> O,

Gets a mutable view into the parts of this GrowBufferMut. Read more
source§

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)

Extends the back of the body towards the end of the buffer, zeroing the new bytes. Read more
source§

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

source§

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§

fn parse<'a, P: ParsablePacket<&'a [u8], ()>>( &'a mut self ) -> Result<P, P::Error>

Parses a packet from the body. Read more
source§

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>

Parses a mutable packet with arguments. Read more
source§

fn parse_mut<'a, P: ParsablePacket<&'a mut [u8], ()>>( &'a mut self ) -> Result<P, P::Error>

Parses a mutable packet from the body. Read more
source§

impl PartialEq for EmptyBuf

source§

fn eq(&self, other: &EmptyBuf) -> bool

This method tests for self and other values to be equal, and is used by ==.
1.0.0 · source§

fn ne(&self, other: &Rhs) -> bool

This method tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
source§

impl ShrinkBuffer for EmptyBuf

source§

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)

Shrinks the back of the body towards the beginning of the buffer. Read more
source§

fn shrink_front_to(&mut self, len: usize)

Shrinks the buffer to be no larger than len bytes, consuming from the front. Read more
source§

fn shrink_back_to(&mut self, len: usize)

Shrinks the buffer to be no larger than len bytes, consuming from the back. Read more
source§

fn shrink<R: RangeBounds<usize>>(&mut self, range: R)

Shrinks the body. Read more
source§

impl ContiguousBuffer for EmptyBuf

source§

impl Copy for EmptyBuf

source§

impl Eq for EmptyBuf

source§

impl StructuralPartialEq for EmptyBuf

Auto Trait Implementations§

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<O, B> AsFragmentedByteSlice<B> for O
where B: Fragment, O: AsMut<[B]>,

source§

fn as_fragmented_byte_slice(&mut self) -> FragmentedByteSlice<'_, B>

Generates a FragmentedByteSlice view of self.
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<B> Serializer for B

§

type Buffer = B

The type of buffers returned from serialization methods on this trait.
source§

fn serialize<BB, P>( self, outer: PacketConstraints, provider: P ) -> Result<BB, (SerializeError<<P as BufferProvider<<B as Serializer>::Buffer, BB>>::Error>, B)>
where BB: GrowBufferMut, P: BufferProvider<<B as Serializer>::Buffer, BB>,

Serializes this Serializer, producing a buffer. Read more
source§

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 more
source§

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 more
source§

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 more
source§

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 more
source§

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 more
source§

fn encapsulate<B>(self, outer: B) -> Nested<Self, B>

Encapsulates this Serializer in another packet, producing a new Serializer. Read more
source§

fn with_size_limit(self, limit: usize) -> Nested<Self, LimitedSizePacketBuilder>

Creates a new Serializer which will enforce a size limit. Read more
source§

impl<T> ToOwned for T
where T: Clone,

§

type Owned = T

The resulting type after obtaining ownership.
source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

§

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>,

§

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.
source§

impl<B> BufferMut for B

source§

impl<B> ContiguousBufferMut for B

source§

impl<B> ReusableBuffer for B