Trait crossmist::Object

source ·
pub trait Object: Sealed {
    // Required methods
    fn serialize_self(&self, s: &mut Serializer);
    fn serialize_slice(elements: &[Self], s: &mut Serializer)
       where Self: Sized;
    unsafe fn deserialize_self(d: &mut Deserializer) -> Result<Self>
       where Self: Sized;
}
Expand description

A serializable object.

This trait is already implemented for most types from the standard library for which it can reasonably be implemented, and if you need it for your structs and enums, you can use #[derive(Object)].

If you need a custom implementation that #[derive(Object)] doesn’t cover (e.g.: a library type crossmist has no information about), implement NonTrivialObject. Object will be implemented automatically in this case.

You don’t need to call the methods of this trait directly: crossmist does this for you whenever you pass objects over channels. In case you need to transmit data via other ways of communication, use Serializer and Deserializer APIs.

Required Methods§

source

fn serialize_self(&self, s: &mut Serializer)

Serialize a single object into a serializer.

source

fn serialize_slice(elements: &[Self], s: &mut Serializer)
where Self: Sized,

Serialize an array of objects into a serializer.

source

unsafe fn deserialize_self(d: &mut Deserializer) -> Result<Self>
where Self: Sized,

Deserialize a single object from a deserializer.

§Safety

This function is safe to call if the order of serialized types during serialization and deserialization matches, up to serialization layout. See the documentation of Deserializer::deserialize for more details.

Implementors§