Trait concordium_std::Serial [−][src]
pub trait Serial {
fn serial<W>(&self, _out: &mut W) -> Result<(), <W as Write>::Err>
where
W: Write;
}Expand description
The Serial trait provides a means of writing structures into byte-sinks
(Write).
Can be derived using #[derive(Serial)] for most cases.
Required methods
Implementations on Foreign Types
Serialize the array by writing elements consecutively starting at 0. Since the length of the array is known statically it is not written out explicitly. Thus serialization of the array A and the slice &A[..] differ.
Serialized if the Option is a None we write 0u8. If Some, we write
1u8 followed by the serialization of the contained T.
impl<K, V> Serial for HashMap<K, V, BuildHasherDefault<FnvHasher>, Global> where
K: Serial,
V: Serial,
impl<K, V> Serial for HashMap<K, V, BuildHasherDefault<FnvHasher>, Global> where
K: Serial,
V: Serial,
The serialization of maps encodes their size as a u32. This should be sufficient for all realistic use cases in smart contracts. They are serialized in no particular order.
Serialization of bool encodes it as a single byte, false is represented
by 0u8 and true is only represented by 1u8.
Serialized by writing an u32 representing the number of bytes for a
utf8-encoding of the string, then writing the bytes. Similar to Vec<_>.
sufficient for all realistic use cases in smart contracts. They are serialized in no particular order.
Implementors
Serialized by writing an u32 representing the number of bytes for a
utf8-encoding of the string, then writing the bytes. Similar to &str.
The serialization of sets encodes their size as a u32. This should be sufficient for all realistic use cases in smart contracts. They are serialized in canonical order (increasing)
The serialization of maps encodes their size as a u32. This should be sufficient for all realistic use cases in smart contracts. They are serialized in ascending order.
Serialized by writing an u32 representing the number of elements, followed
by the elements serialized according to their type T.
