Crate postcard_core

Crate postcard_core 

Source
Expand description

§Postcard Core

postcard-core contains the minimal logic necessary for encoding data to and decoding data from the postcard wire format. It is not coupled to any specific serialization or deserialization framework, and is intended to be usable when writing a custom postcard serializer or deserializer.

For an example of usage of this crate, see the postcard2 crate, which uses postcard-core to implement a serde compatible serializer/deserializer.

§Primitive items

The following are all “primitive” data types. They are directly serialized and deserialized.

§Enum Variants

The following are all Tagged Union items. The listed serializer and deserializer allow for pushing or taking ONLY the discriminant. For serialization, the “body” must then be written if necessary. For deserialization, the discriminant must be used to determine if and how to take the remainder of the tagged union item.

§Length prefixed items

The following are all length-prefixed items. They begin with a varint(usize), which determines the number of items in the item. This many items must then be serialized or deserialized.

For string and byte array, “temp” variants are provided that yield borrowed items that are not required to live for the entire lifetime of the Flavor’s buffer. This is useful when then yielded item is immediately going to be converted into an owned item, e.g. a Vec<u8> or String.

This is an implementation detail only - there is no functional different in deserialization, but may influence the Flavor interactions. See de::Flavor::try_take_n() and de::Flavor::try_take_n_temp() for more details.

string and byte array are also unique in that the provide borrowed views to the deserialized data.

§Omitted items

The following items are not encoded to the wire, and therefore have no serializer and deserializers.

#TypeSerializerDeserializer
18unitN/AN/A
19unit structN/AN/A

§Unheadered Aggregates

The following items contain any number of subitems, however the “container” item itself does not require any data to be written to or read from the wire. This means that only their child items, if any, need to be serialized or deserialized.

#TypeSerializerDeserializer
21newtype structN/AN/A
24tupleN/AN/A
25tuple structN/AN/A
28structN/AN/A

§Schema

#TypeSerializerDeserializer
32schemaTODO: SchemaTODO: Schema

Modules§

de
Deserializing tools
ser
Serializing tools
varint
Varint tools