[][src]Trait kompact::prelude::Serialiser

pub trait Serialiser<T>: Send {
    fn ser_id(&self) -> SerId;
fn serialise(&self, v: &T, buf: &mut dyn BufMut) -> Result<(), SerError>; fn size_hint(&self) -> Option<usize> { ... } }

A trait for types that can serialise data of type T

Required methods

fn ser_id(&self) -> SerId

The serialisation id for this serialiser

Serialisation ids are used to determine the deserialiser to use with a particular byte buffer. They are prepended to the actual serialised data and read first during deserialisation. Serialisation ids must be globally unique within a distributed Kompact system.

fn serialise(&self, v: &T, buf: &mut dyn BufMut) -> Result<(), SerError>

Serialise v into buf.

Serialisation should produce a copy, and not consume the original value.

Returns a SerError if unsuccessful.

Loading content...

Provided methods

fn size_hint(&self) -> Option<usize>

An indicator how many bytes must be reserved in a buffer for a value to be serialsed into it with this serialiser

If the total size is unknown, None should be returned.

Generally, size hints should be cheap to calculate, compared to the actual serialisation, since they are simply optimisations to avoid many small memory allocations during the serialisation process.

Loading content...

Implementors

impl<T> Serialiser<T> for Serde where
    T: Serialize + SerialisationId + Debug + Send + 'static, 
[src]

Loading content...