Trait rkyv::ser::Serializer [−][src]
pub trait Serializer: Fallible { fn pos(&self) -> usize; fn write(&mut self, bytes: &[u8]) -> Result<(), Self::Error>; fn pad(&mut self, padding: usize) -> Result<(), Self::Error> { ... } fn align(&mut self, align: usize) -> Result<usize, Self::Error> { ... } fn align_for<T>(&mut self) -> Result<usize, Self::Error> { ... } unsafe fn resolve_aligned<T: Archive + ?Sized>(
&mut self,
value: &T,
resolver: T::Resolver
) -> Result<usize, Self::Error> { ... } fn serialize_value<T: Serialize<Self>>(
&mut self,
value: &T
) -> Result<usize, Self::Error> { ... } unsafe fn resolve_unsized_aligned<T: ArchiveUnsized + ?Sized>(
&mut self,
value: &T,
to: usize,
metadata_resolver: T::MetadataResolver
) -> Result<usize, Self::Error> { ... } fn serialize_unsized_value<T: SerializeUnsized<Self> + ?Sized>(
&mut self,
value: &T
) -> Result<usize, Self::Error> { ... } }
A byte sink that knows where it is.
A type that is io::Write
can be wrapped in a
WriteSerializer
to equip it with Serializer
.
It’s important that the memory for archived objects is properly aligned before attempting to
read objects out of it; use the Aligned
wrapper if it’s appropriate.
Required methods
fn pos(&self) -> usize
[src]
Returns the current position of the serializer.
fn write(&mut self, bytes: &[u8]) -> Result<(), Self::Error>
[src]
Attempts to write the given bytes to the serializer.
Provided methods
fn pad(&mut self, padding: usize) -> Result<(), Self::Error>
[src]
Advances the given number of bytes as padding.
fn align(&mut self, align: usize) -> Result<usize, Self::Error>
[src]
Aligns the position of the serializer to the given alignment.
fn align_for<T>(&mut self) -> Result<usize, Self::Error>
[src]
Aligns the position of the serializer to be suitable to write the given type.
unsafe fn resolve_aligned<T: Archive + ?Sized>(
&mut self,
value: &T,
resolver: T::Resolver
) -> Result<usize, Self::Error>
[src]
&mut self,
value: &T,
resolver: T::Resolver
) -> Result<usize, Self::Error>
Resolves the given value with its resolver and writes the archived type.
Returns the position of the written archived type.
Safety
The caller must guarantee that the serializer is aligned for the archived version of the given type.
fn serialize_value<T: Serialize<Self>>(
&mut self,
value: &T
) -> Result<usize, Self::Error>
[src]
&mut self,
value: &T
) -> Result<usize, Self::Error>
Archives the given object and returns the position it was archived at.
unsafe fn resolve_unsized_aligned<T: ArchiveUnsized + ?Sized>(
&mut self,
value: &T,
to: usize,
metadata_resolver: T::MetadataResolver
) -> Result<usize, Self::Error>
[src]
&mut self,
value: &T,
to: usize,
metadata_resolver: T::MetadataResolver
) -> Result<usize, Self::Error>
Resolves the given reference with its resolver and writes the archived reference.
Returns the position of the written archived reference.
Safety
The caller must guarantee that the serializer is aligned for the archived reference of the given type.
fn serialize_unsized_value<T: SerializeUnsized<Self> + ?Sized>(
&mut self,
value: &T
) -> Result<usize, Self::Error>
[src]
&mut self,
value: &T
) -> Result<usize, Self::Error>
Archives a reference to the given object and returns the position it was archived at.
Implementors
impl<A: Borrow<AlignedVec> + BorrowMut<AlignedVec>> Serializer for AlignedSerializer<A>
[src]
impl<A: Borrow<AlignedVec> + BorrowMut<AlignedVec>> Serializer for AlignedSerializer<A>
[src]fn pos(&self) -> usize
[src]
fn write(&mut self, bytes: &[u8]) -> Result<(), Self::Error>
[src]
unsafe fn resolve_aligned<T: Archive + ?Sized>(
&mut self,
value: &T,
resolver: T::Resolver
) -> Result<usize, Self::Error>
[src]
&mut self,
value: &T,
resolver: T::Resolver
) -> Result<usize, Self::Error>
unsafe fn resolve_unsized_aligned<T: ArchiveUnsized + ?Sized>(
&mut self,
value: &T,
to: usize,
metadata_resolver: T::MetadataResolver
) -> Result<usize, Self::Error>
[src]
&mut self,
value: &T,
to: usize,
metadata_resolver: T::MetadataResolver
) -> Result<usize, Self::Error>
impl<S: Serializer> Serializer for SharedSerializerAdapter<S>
[src]
impl<S: Serializer> Serializer for SharedSerializerAdapter<S>
[src]fn pos(&self) -> usize
[src]
fn write(&mut self, bytes: &[u8]) -> Result<(), Self::Error>
[src]
fn pad(&mut self, padding: usize) -> Result<(), Self::Error>
[src]
fn align(&mut self, align: usize) -> Result<usize, Self::Error>
[src]
fn align_for<T>(&mut self) -> Result<usize, Self::Error>
[src]
unsafe fn resolve_aligned<T: Archive + ?Sized>(
&mut self,
value: &T,
resolver: T::Resolver
) -> Result<usize, Self::Error>
[src]
&mut self,
value: &T,
resolver: T::Resolver
) -> Result<usize, Self::Error>