pub struct PodSerializer<O: Write + Seek> { /* private fields */ }
Expand description

This struct is responsible for serializing a PodSerialize implementor into the raw POD format.

Implementations§

source§

impl<O: Write + Seek> PodSerializer<O>

source

pub fn serialize<P>(out: O, pod: &P) -> Result<(O, u64), GenError>
where P: PodSerialize + ?Sized,

Serialize the provided POD into the raw pod format, writing it into out.

When serializing into an in-memory-buffer such as Vec, you might have to wrap it into a std::io::Cursor to provide the Seek trait.

The function returns back the out writer and the number of bytes written, or a generation error if serialization failed.

source

pub fn serialized_fixed_sized_pod<P>( self, pod: &P ) -> Result<SerializeSuccess<O>, GenError>
where P: FixedSizedPod + ?Sized,

Serialize any fixed size pod.

The type of the serialized pod will depend on the FixedSizedPod::CanonicalType that the passed type has.

source

pub fn serialize_string( self, string: &str ) -> Result<SerializeSuccess<O>, GenError>

Serialize a String pod.

source

pub fn serialize_bytes( self, bytes: &[u8] ) -> Result<SerializeSuccess<O>, GenError>

Serialize a Bytes pod.

source

pub fn serialize_array<P: FixedSizedPod>( self, length: u32 ) -> Result<ArrayPodSerializer<O, P>, GenError>

Begin serializing an Array pod with exactly length elements.

source

pub fn serialize_struct(self) -> Result<StructPodSerializer<O>, GenError>

Begin serializing a Struct pod.

source

pub fn serialize_object( self, object_type: u32, object_id: u32 ) -> Result<ObjectPodSerializer<O>, GenError>

Begin serializing an Object pod.

source

pub fn serialize_choice<T: CanonicalFixedSizedPod>( self, choice: &Choice<T> ) -> Result<SerializeSuccess<O>, GenError>

Serialize a Choice pod.

source

pub fn serialize_pointer<T>( self, type_: u32, ptr: *const T ) -> Result<SerializeSuccess<O>, GenError>

Serialize a pointer pod.

Auto Trait Implementations§

§

impl<O> RefUnwindSafe for PodSerializer<O>
where O: RefUnwindSafe,

§

impl<O> Send for PodSerializer<O>
where O: Send,

§

impl<O> Sync for PodSerializer<O>
where O: Sync,

§

impl<O> Unpin for PodSerializer<O>
where O: Unpin,

§

impl<O> UnwindSafe for PodSerializer<O>
where O: UnwindSafe,

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

§

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.