Trait ergo_lib::serialization::SigmaSerializable [−][src]
Consensus-critical serialization for Ergo
Required methods
fn sigma_serialize<W: SigmaByteWrite>(&self, w: &mut W) -> Result<(), Error>
[src]
Write self
to the given writer
.
This function has a sigma_
prefix to alert the reader that the
serialization in use is consensus-critical serialization
Notice that the error type is std::io::Error
; this indicates that
serialization MUST be infallible up to errors in the underlying writer.
In other words, any type implementing SigmaSerializable
must make illegal states unrepresentable.
fn sigma_parse<R: SigmaByteRead>(r: &mut R) -> Result<Self, SerializationError>
[src]
Try to read self
from the given reader
.
sigma-
prefix to alert the reader that the serialization in use
is consensus-critical
Provided methods
fn sigma_serialize_bytes(&self) -> Vec<u8>
[src]
Serialize any SigmaSerializable value into bytes
fn sigma_parse_bytes(bytes: Vec<u8>) -> Result<Self, SerializationError>
[src]
Parse self
from the bytes
Implementations on Foreign Types
impl<T: SigmaSerializable> SigmaSerializable for Vec<T>
[src]
fn sigma_serialize<W: SigmaByteWrite>(&self, w: &mut W) -> Result<(), Error>
[src]
fn sigma_parse<R: SigmaByteRead>(r: &mut R) -> Result<Self, SerializationError>
[src]
impl<T: SigmaSerializable> SigmaSerializable for Option<Box<T>>
[src]
fn sigma_serialize<W: SigmaByteWrite>(&self, w: &mut W) -> Result<(), Error>
[src]
fn sigma_parse<R: SigmaByteRead>(r: &mut R) -> Result<Self, SerializationError>
[src]
Implementors
impl SigmaSerializable for RegisterId
[src]
fn sigma_serialize<W: SigmaByteWrite>(&self, w: &mut W) -> Result<(), Error>
[src]
fn sigma_parse<R: SigmaByteRead>(r: &mut R) -> Result<Self, SerializationError>
[src]
impl SigmaSerializable for ProofBytes
[src]
fn sigma_serialize<W: SigmaByteWrite>(&self, w: &mut W) -> Result<(), Error>
[src]
fn sigma_parse<R: SigmaByteRead>(r: &mut R) -> Result<Self, SerializationError>
[src]
impl SigmaSerializable for SigmaBoolean
[src]
fn sigma_serialize<W: SigmaByteWrite>(&self, w: &mut W) -> Result<(), Error>
[src]
fn sigma_parse<R: SigmaByteRead>(r: &mut R) -> Result<Self, SerializationError>
[src]
impl SigmaSerializable for SType
[src]
Each SType is serialized to array of bytes by:
- emitting typeCode of each node (see special case for collections below)
- then recursively serializing subtrees from left to right on each level
- for each collection of primitive type there is special type code to emit single byte instead of two bytes Types code intervals
- (1 .. MaxPrimTypeCode) // primitive types
- (CollectionTypeCode .. CollectionTypeCode + MaxPrimTypeCode) // collections of primitive types
- (MaxCollectionTypeCode ..) // Other types Collection of non-primitive type is serialized as (CollectionTypeCode, serialize(elementType))