rkyv::ser

Trait SharedSerializeRegistry

Source
pub trait SharedSerializeRegistry: Fallible {
    // Required methods
    fn get_shared_ptr(&self, value: *const u8) -> Option<usize>;
    fn add_shared_ptr(
        &mut self,
        value: *const u8,
        pos: usize,
    ) -> Result<(), Self::Error>;

    // Provided methods
    fn get_shared<T: ?Sized>(&self, value: &T) -> Option<usize> { ... }
    fn add_shared<T: ?Sized>(
        &mut self,
        value: &T,
        pos: usize,
    ) -> Result<(), Self::Error> { ... }
    fn serialize_shared<T: SerializeUnsized<Self> + ?Sized>(
        &mut self,
        value: &T,
    ) -> Result<usize, Self::Error>
       where Self: Serializer { ... }
}
Expand description

A registry that tracks serialized shared memory.

This trait is required to serialize shared pointers.

Required Methods§

Source

fn get_shared_ptr(&self, value: *const u8) -> Option<usize>

Gets the position of a previously-added shared pointer.

Returns None if the pointer has not yet been added.

Source

fn add_shared_ptr( &mut self, value: *const u8, pos: usize, ) -> Result<(), Self::Error>

Adds the position of a shared pointer to the registry.

Provided Methods§

Source

fn get_shared<T: ?Sized>(&self, value: &T) -> Option<usize>

Gets the position of a previously-added shared value.

Returns None if the value has not yet been added.

Source

fn add_shared<T: ?Sized>( &mut self, value: &T, pos: usize, ) -> Result<(), Self::Error>

Adds the position of a shared value to the registry.

Source

fn serialize_shared<T: SerializeUnsized<Self> + ?Sized>( &mut self, value: &T, ) -> Result<usize, Self::Error>
where Self: Serializer,

Archives the given shared value and returns its position. If the value has already been added then it returns the position of the previously added value.

Dyn Compatibility§

This trait is not dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.

Implementors§