BinarySerdeBuf

Struct BinarySerdeBuf 

Source
pub struct BinarySerdeBuf<'a> { /* private fields */ }
Expand description

a binary serializer and deserializes which serializes and deserializes values to or from a buffer.

Implementations§

Source§

impl<'a> BinarySerdeBuf<'a>

Source

pub fn new(buf: &'a mut [u8], endianness: Endianness) -> Self

creates a new binary serializer/deserializer which serializes/deserializer values to/from the given buffer using the given endianness.

Source

pub fn serialize<T: BinarySerde>(&mut self, value: &T)

serializes a value of type T into the current position in the buffer, and advances the position accordingly.

§Panics

this function panics if the serialization exceeds the bounds of the buffer.

Source

pub fn consume_bytes(&mut self, amount: usize) -> &[u8]

consumes and returns the next amount bytes from the current position in the buffer, and advances the position accordingly.

§Panics

this function panics if the requested amount of bytes exceeds the bounds of the buffer.

Source

pub fn deserialize<T: BinarySerde>(&mut self) -> Result<T, DeserializeError>

deserializes a value of type T from the current position in the buffer, and advances the position accordingly.

§Panics

this function panics if the deserialization exceeds the bounds of the buffer.

Source

pub fn position(&self) -> usize

returns the current position of this deserializer in the buffer.

Source

pub fn set_position(&mut self, new_position: usize)

sets the position of this deserializer in the buffer.

Source

pub fn move_forwards(&mut self, amount: usize)

moves this deserializer’s position forwards according to the given amount.

Source

pub fn move_backwards(&mut self, amount: usize)

moves this deserializer’s position backwards according to the given amount.

Source

pub fn set_endianness(&mut self, new_endianness: Endianness)

sets the endianness of this serializer/deserializer

Source

pub fn endianness(&self) -> Endianness

returns the endianness of this serializer/deserializer.

Source

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

returns a reference to the underlying buffer of this serializer/deserializer.

Auto Trait Implementations§

§

impl<'a> Freeze for BinarySerdeBuf<'a>

§

impl<'a> RefUnwindSafe for BinarySerdeBuf<'a>

§

impl<'a> Send for BinarySerdeBuf<'a>

§

impl<'a> Sync for BinarySerdeBuf<'a>

§

impl<'a> Unpin for BinarySerdeBuf<'a>

§

impl<'a> !UnwindSafe for BinarySerdeBuf<'a>

Blanket Implementations§

§

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

§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
§

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

§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
§

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

§

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

Mutably borrows from an owned value. Read more
§

impl<T> From<T> for T

§

fn from(t: T) -> T

Returns the argument unchanged.

§

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

§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

§

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

§

type Error = Infallible

The type returned in the event of a conversion error.
§

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

Performs the conversion.
§

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

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

Performs the conversion.