Trait strict_encoding::StrictEncode[][src]

pub trait StrictEncode {
    fn strict_encode<E: Write>(&self, e: E) -> Result<usize, Error>;

    fn strict_serialize(&self) -> Result<Vec<u8>, Error> { ... }
}
Expand description

Binary encoding according to the strict rules that usually apply to consensus-critical data structures. May be used for network communications; in some circumstances may be used for commitment procedures; however it must be kept in mind that sometime commitment may follow “fold” scheme (Merklization or nested commitments) and in such cases this trait can’t be applied. It is generally recommended for consensus-related commitments to utilize [CommitVerify], [TryCommitVerify] and [EmbedCommitVerify] traits
from [paradigms::commit_verify] module.

Required methods

fn strict_encode<E: Write>(&self, e: E) -> Result<usize, Error>[src]

Expand description

Encode with the given [std::io::Writer] instance; must return result with either amount of bytes encoded – or implementation-specific error type.

Loading content...

Provided methods

fn strict_serialize(&self) -> Result<Vec<u8>, Error>[src]

Expand description

Serializes data as a byte array using [strict_encode()] function

Loading content...

Implementations on Foreign Types

impl StrictEncode for FlagVec[src]

fn strict_encode<E: Write>(&self, e: E) -> Result<usize, Error>[src]

impl StrictEncode for u256[src]

fn strict_encode<E: Write>(&self, e: E) -> Result<usize, Error>[src]

impl StrictEncode for u512[src]

fn strict_encode<E: Write>(&self, e: E) -> Result<usize, Error>[src]

impl StrictEncode for u1024[src]

fn strict_encode<E: Write>(&self, e: E) -> Result<usize, Error>[src]

impl<T> StrictEncode for Option<T> where
    T: StrictEncode
[src]

In terms of strict encoding, Option (optional values) are
represented by a significator byte, which MUST be either 0 (for no value present) or 1, followed by the value strict encoding.

fn strict_encode<E: Write>(&self, e: E) -> Result<usize, Error>[src]

impl<T> StrictEncode for Vec<T> where
    T: StrictEncode
[src]

In terms of strict encoding, Vec is stored in form of usize-encoded length (see StrictEncode implementation for usize type for encoding platform-independent constant-length encoding rules) followed by a consequently-encoded vec items, according to their type.

fn strict_encode<E: Write>(&self, e: E) -> Result<usize, Error>[src]

impl<T> StrictEncode for HashSet<T> where
    T: StrictEncode + Eq + Ord + Hash + Debug
[src]

Strict encoding for a unique value collection represented by a rust HashSet type is performed in the same way as Vec encoding. NB: Array members must are ordered with the sort operation, so type T must implement Ord trait in such a way that it produces deterministically-sorted result

fn strict_encode<E: Write>(&self, e: E) -> Result<usize, Error>[src]

impl<T> StrictEncode for BTreeSet<T> where
    T: StrictEncode + Eq + Ord + Debug
[src]

Strict encoding for a unique value collection represented by a rust BTreeSet type is performed in the same way as Vec encoding. NB: Array members must are ordered with the sort operation, so type T must implement Ord trait in such a way that it produces deterministically-sorted result

fn strict_encode<E: Write>(&self, e: E) -> Result<usize, Error>[src]

impl<T> StrictEncode for HashMap<usize, T> where
    T: StrictEncode + Clone
[src]

LNP/BP library uses HashMap<usize, T: StrictEncode>s to encode ordered lists, where the position of the list item must be fixed, since the item is referenced from elsewhere by its index. Thus, the library does not supports and recommends not to support strict encoding of any other HashMap variants.

Strict encoding of the HashMap<usize, T> type is performed by converting into a fixed-order Vec<T> and serializing it according to the Vec strict encoding rules. This operation is internally performed via conversion into BTreeMap<usize, T: StrictEncode>.

fn strict_encode<E: Write>(&self, e: E) -> Result<usize, Error>[src]

impl<K, V> StrictEncode for BTreeMap<K, V> where
    K: StrictEncode + Ord + Clone,
    V: StrictEncode + Clone
[src]

LNP/BP library uses BTreeMap<usize, T: StrictEncode>s to encode ordered lists, where the position of the list item must be fixed, since the item is referenced from elsewhere by its index. Thus, the library does not supports and recommends not to support strict encoding of any other BTreeMap variants.

Strict encoding of the BTreeMap<usize, T> type is performed by converting into a fixed-order Vec<T> and serializing it according to the Vec strict encoding rules.

fn strict_encode<E: Write>(&self, e: E) -> Result<usize, Error>[src]

impl<K, V> StrictEncode for (K, V) where
    K: StrictEncode + Clone,
    V: StrictEncode + Clone
[src]

Two-component tuples are encoded as they were fields in the parent data structure

fn strict_encode<E: Write>(&self, e: E) -> Result<usize, Error>[src]

impl StrictEncode for &[u8][src]

fn strict_encode<E: Write>(&self, e: E) -> Result<usize, Error>[src]

impl StrictEncode for [u8; 16][src]

fn strict_encode<E: Write>(&self, e: E) -> Result<usize, Error>[src]

impl StrictEncode for [u8; 20][src]

fn strict_encode<E: Write>(&self, e: E) -> Result<usize, Error>[src]

impl StrictEncode for [u8; 32][src]

fn strict_encode<E: Write>(&self, e: E) -> Result<usize, Error>[src]

impl StrictEncode for [u8; 64][src]

fn strict_encode<E: Write>(&self, e: E) -> Result<usize, Error>[src]

impl StrictEncode for Box<[u8]>[src]

fn strict_encode<E: Write>(&self, e: E) -> Result<usize, Error>[src]

impl<T> StrictEncode for Rc<T> where
    T: StrictEncode
[src]

fn strict_encode<E: Write>(&self, e: E) -> Result<usize, Error>[src]

impl<T> StrictEncode for RefCell<T> where
    T: StrictEncode
[src]

fn strict_encode<E: Write>(&self, e: E) -> Result<usize, Error>[src]

impl<T> StrictEncode for Arc<T> where
    T: StrictEncode
[src]

fn strict_encode<E: Write>(&self, e: E) -> Result<usize, Error>[src]

impl StrictEncode for &str[src]

fn strict_encode<E: Write>(&self, e: E) -> Result<usize, Error>[src]

impl StrictEncode for String[src]

fn strict_encode<E: Write>(&self, e: E) -> Result<usize, Error>[src]

impl StrictEncode for bool[src]

fn strict_encode<E: Write>(&self, e: E) -> Result<usize, Error>[src]

impl StrictEncode for u8[src]

fn strict_encode<E: Write>(&self, e: E) -> Result<usize, Error>[src]

impl StrictEncode for i8[src]

fn strict_encode<E: Write>(&self, e: E) -> Result<usize, Error>[src]

impl StrictEncode for u16[src]

fn strict_encode<E: Write>(&self, e: E) -> Result<usize, Error>[src]

impl StrictEncode for i16[src]

fn strict_encode<E: Write>(&self, e: E) -> Result<usize, Error>[src]

impl StrictEncode for u32[src]

fn strict_encode<E: Write>(&self, e: E) -> Result<usize, Error>[src]

impl StrictEncode for i32[src]

fn strict_encode<E: Write>(&self, e: E) -> Result<usize, Error>[src]

impl StrictEncode for u64[src]

fn strict_encode<E: Write>(&self, e: E) -> Result<usize, Error>[src]

impl StrictEncode for i64[src]

fn strict_encode<E: Write>(&self, e: E) -> Result<usize, Error>[src]

impl StrictEncode for u128[src]

fn strict_encode<E: Write>(&self, e: E) -> Result<usize, Error>[src]

impl StrictEncode for i128[src]

fn strict_encode<E: Write>(&self, e: E) -> Result<usize, Error>[src]

impl StrictEncode for usize[src]

fn strict_encode<E: Write>(&self, e: E) -> Result<usize, Error>[src]

impl StrictEncode for f32[src]

fn strict_encode<E: Write>(&self, e: E) -> Result<usize, Error>[src]

impl StrictEncode for f64[src]

fn strict_encode<E: Write>(&self, e: E) -> Result<usize, Error>[src]

impl StrictEncode for Duration[src]

fn strict_encode<E: Write>(&self, e: E) -> Result<usize, Error>[src]

impl StrictEncode for NaiveDateTime[src]

fn strict_encode<E: Write>(&self, e: E) -> Result<usize, Error>[src]

impl StrictEncode for DateTime<Utc>[src]

fn strict_encode<E: Write>(&self, e: E) -> Result<usize, Error>[src]

impl<W> StrictEncode for Holder<W, Wrapped> where
    W: Wrapper,
    W::Inner: StrictEncode
[src]

fn strict_encode<E: Write>(&self, e: E) -> Result<usize, Error>[src]

impl<H> StrictEncode for Holder<H, HashFixedBytes> where
    H: Hash
[src]

fn strict_encode<E: Write>(&self, e: E) -> Result<usize, Error>[src]

impl<A> StrictEncode for Holder<A, UsingUniformAddr> where
    A: Uniform
[src]

fn strict_encode<E: Write>(&self, e: E) -> Result<usize, Error>[src]

Loading content...

Implementors

impl StrictEncode for AddrFormat[src]

fn strict_encode<E: Write>(&self, e: E) -> Result<usize, Error>[src]

impl StrictEncode for Transport[src]

fn strict_encode<E: Write>(&self, e: E) -> Result<usize, Error>[src]

impl StrictEncode for RawAddr[src]

fn strict_encode<E: Write>(&self, e: E) -> Result<usize, Error>[src]

impl StrictEncode for RawUniformAddr[src]

fn strict_encode<E: Write>(&self, e: E) -> Result<usize, Error>[src]

impl<T> StrictEncode for T where
    T: Strategy + Clone,
    Holder<T, <T as Strategy>::Strategy>: StrictEncode
[src]

fn strict_encode<E: Write>(&self, e: E) -> Result<usize, Error>[src]

Loading content...