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

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<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<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

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

Source§

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.