Struct packet::SerializeBuffer

source ·
pub struct SerializeBuffer<'a, 'b> { /* private fields */ }
Expand description

A view into a TargetBuffer used for serializing new packets.

A SerializeBuffer is a view into a TargetBuffer which is used by the PacketBuilder::serialize method to serialize a new packet. It is constructed with a contiguous header and footer, and a potentially fragmented body, typically obtained from TargetBuffer::with_parts.

A SerializeBuffer provides separate access to the bytes which will store the header, body, and footer of the new packet. The body is initialized to contain the bytes of the packet to be encapsulated (including any padding), and it is the caller’s responsibility to serialize the header and footer.

Implementations§

source§

impl<'a, 'b> SerializeBuffer<'a, 'b>

source

pub fn new( header: &'a mut [u8], body: FragmentedBytesMut<'a, 'b>, footer: &'a mut [u8] ) -> SerializeBuffer<'a, 'b>

Constructs a new SerializeBuffer.

new constructs a new SerializeBuffer with the provided header, body, and footer parts.

source

pub fn header(&mut self) -> &mut [u8]

Gets the bytes of the header.

source

pub fn body(&mut self) -> &mut FragmentedBytesMut<'a, 'b>

Gets the bytes of the body.

source

pub fn footer(&mut self) -> &mut [u8]

Gets the bytes of the footer.

source

pub fn parts( &mut self ) -> (&mut [u8], &mut FragmentedBytesMut<'a, 'b>, &mut [u8])

Gets the bytes of the header, body, and footer.

parts gets references to the header, body, and footer all at once. Because of lifetime rules and the fact that the header, body, and footer methods borrow this SerializeBuffer, this is the only way to construct and operate on references to more than one section of the buffer at a time.

source

pub fn len(&self) -> usize

Gets the total length of this SerializeBuffer, equal to the sum of the lengths of header, body, and footer.

Auto Trait Implementations§

§

impl<'a, 'b> RefUnwindSafe for SerializeBuffer<'a, 'b>

§

impl<'a, 'b> Send for SerializeBuffer<'a, 'b>

§

impl<'a, 'b> Sync for SerializeBuffer<'a, 'b>

§

impl<'a, 'b> Unpin for SerializeBuffer<'a, 'b>where 'b: 'a,

§

impl<'a, 'b> !UnwindSafe for SerializeBuffer<'a, 'b>

Blanket Implementations§

source§

impl<T> Any for Twhere T: 'static + ?Sized,

source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
source§

impl<T> Borrow<T> for Twhere T: ?Sized,

const: unstable · source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
source§

impl<T> BorrowMut<T> for Twhere T: ?Sized,

const: unstable · source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
source§

impl<T> From<T> for T

const: unstable · source§

fn from(t: T) -> T

Returns the argument unchanged.

source§

impl<T, U> Into<U> for Twhere U: From<T>,

const: unstable · 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 Twhere U: Into<T>,

§

type Error = Infallible

The type returned in the event of a conversion error.
const: unstable · source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
source§

impl<T, U> TryInto<U> for Twhere U: TryFrom<T>,

§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
const: unstable · source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.