Struct crossmist::serde::Serializer

source ·
pub struct Serializer { /* private fields */ }
Expand description

Stateful serialization.

Implementations§

source§

impl Serializer

source

pub fn new() -> Self

Create a new serializer.

source

pub fn write(&mut self, data: &[u8])

Append chunk of serialize data.

source

pub fn serialize<T: Object + ?Sized>(&mut self, data: &T)

Append serialized data of an object.

source

pub fn serialize_slice<T: Object>(&mut self, data: &[T])

Append serialized data of a slice of objects, as if calling Serializer::serialize for each element.

source

pub fn add_handle(&mut self, handle: RawHandle) -> usize

Store a file handle, returning its index.

source

pub fn drain_handles(&mut self) -> Vec<RawHandle>

Get a list of added file handles.

source

pub fn learn_cyclic(&mut self, ptr: *const c_void) -> Option<NonZeroUsize>

Check if an object has already been serialized in this session and return its index.

source

pub fn into_vec(self) -> Vec<u8>

Extract serialized data.

Trait Implementations§

source§

impl IntoIterator for Serializer

§

type Item = u8

The type of the elements being iterated over.
§

type IntoIter = <Vec<u8, Global> as IntoIterator>::IntoIter

Which kind of iterator are we turning this into?
source§

fn into_iter(self) -> Self::IntoIter

Creates an iterator from a value. Read more

Auto Trait Implementations§

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,

source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
source§

impl<T> BorrowMut<T> for Twhere 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 Twhere 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 Twhere 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 Twhere 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.