[−][src]Trait kompact::prelude::Serialiser
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.
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.
Implementors
impl<T> Serialiser<T> for Serde where
T: Serialize + SerialisationId + Debug + Send + 'static,
[src]
T: Serialize + SerialisationId + Debug + Send + 'static,