Struct libspa::pod::serialize::PodSerializer
source · 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>
impl<O: Write + Seek> PodSerializer<O>
sourcepub fn serialize<P>(out: O, pod: &P) -> Result<(O, u64), GenError>where
P: PodSerialize + ?Sized,
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.
sourcepub fn serialized_fixed_sized_pod<P>(
self,
pod: &P
) -> Result<SerializeSuccess<O>, GenError>where
P: FixedSizedPod + ?Sized,
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.
sourcepub fn serialize_string(
self,
string: &str
) -> Result<SerializeSuccess<O>, GenError>
pub fn serialize_string( self, string: &str ) -> Result<SerializeSuccess<O>, GenError>
Serialize a String
pod.
sourcepub fn serialize_bytes(
self,
bytes: &[u8]
) -> Result<SerializeSuccess<O>, GenError>
pub fn serialize_bytes( self, bytes: &[u8] ) -> Result<SerializeSuccess<O>, GenError>
Serialize a Bytes
pod.
sourcepub fn serialize_array<P: FixedSizedPod>(
self,
length: u32
) -> Result<ArrayPodSerializer<O, P>, GenError>
pub fn serialize_array<P: FixedSizedPod>( self, length: u32 ) -> Result<ArrayPodSerializer<O, P>, GenError>
Begin serializing an Array
pod with exactly length
elements.
sourcepub fn serialize_struct(self) -> Result<StructPodSerializer<O>, GenError>
pub fn serialize_struct(self) -> Result<StructPodSerializer<O>, GenError>
Begin serializing a Struct
pod.
sourcepub fn serialize_object(
self,
object_type: u32,
object_id: u32
) -> Result<ObjectPodSerializer<O>, GenError>
pub fn serialize_object( self, object_type: u32, object_id: u32 ) -> Result<ObjectPodSerializer<O>, GenError>
Begin serializing an Object
pod.
sourcepub fn serialize_choice<T: CanonicalFixedSizedPod>(
self,
choice: &Choice<T>
) -> Result<SerializeSuccess<O>, GenError>
pub fn serialize_choice<T: CanonicalFixedSizedPod>( self, choice: &Choice<T> ) -> Result<SerializeSuccess<O>, GenError>
Serialize a Choice
pod.
sourcepub fn serialize_pointer<T>(
self,
type_: u32,
ptr: *const T
) -> Result<SerializeSuccess<O>, GenError>
pub fn serialize_pointer<T>( self, type_: u32, ptr: *const T ) -> Result<SerializeSuccess<O>, GenError>
Serialize a pointer pod.