Trait rkyv_dyn::DynSerializer[][src]

pub trait DynSerializer {
    fn pos_dyn(&self) -> usize;
fn write_dyn(&mut self, bytes: &[u8]) -> Result<(), DynError>; }
Expand description

An object-safe version of Serializer.

Instead of an associated error type, DynSerializer returns the DynError type. If you have a serializer that already implements Serializer, then it will automatically implement DynSerializer.

Required methods

fn pos_dyn(&self) -> usize[src]

Returns the current position of the serializer.

fn write_dyn(&mut self, bytes: &[u8]) -> Result<(), DynError>[src]

Attempts to write the given bytes to the serializer.

Trait Implementations

impl<'a> Fallible for dyn DynSerializer + 'a[src]

type Error = DynError

The error produced by any failing methods

impl<'a> Serializer for dyn DynSerializer + 'a[src]

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.

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>(
    &mut self,
    value: &T,
    resolver: <T as Archive>::Resolver
) -> Result<usize, Self::Error> where
    T: Archive + ?Sized
[src]

Resolves the given value with its resolver and writes the archived type. Read more

fn serialize_value<T>(&mut self, value: &T) -> Result<usize, Self::Error> where
    T: Serialize<Self>, 
[src]

Archives the given object and returns the position it was archived at.

unsafe fn resolve_unsized_aligned<T>(
    &mut self,
    value: &T,
    to: usize,
    metadata_resolver: <T as ArchiveUnsized>::MetadataResolver
) -> Result<usize, Self::Error> where
    T: ArchiveUnsized + ?Sized
[src]

Resolves the given reference with its resolver and writes the archived reference. Read more

fn serialize_unsized_value<T>(
    &mut self,
    value: &T
) -> Result<usize, Self::Error> where
    T: SerializeUnsized<Self> + ?Sized
[src]

Archives a reference to the given object and returns the position it was archived at.

Implementations on Foreign Types

impl<S: Serializer + ?Sized> DynSerializer for &mut S[src]

fn pos_dyn(&self) -> usize[src]

fn write_dyn(&mut self, bytes: &[u8]) -> Result<(), DynError>[src]

Implementors