[][src]Trait strict_encoding::StrictEncode

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

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

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

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

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

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

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

Loading content...

Implementations on Foreign Types

impl StrictEncode for Script[src]

impl StrictEncode for SecretKey[src]

impl StrictEncode for PublicKey[src]

impl StrictEncode for Signature[src]

impl StrictEncode for PublicKey[src]

impl StrictEncode for Network[src]

impl StrictEncode for ChildNumber[src]

impl StrictEncode for DerivationPath[src]

impl StrictEncode for ChainCode[src]

impl StrictEncode for Fingerprint[src]

impl StrictEncode for ExtendedPubKey[src]

impl StrictEncode for ExtendedPrivKey[src]

impl StrictEncode for &[u8][src]

impl StrictEncode for [u8; 32][src]

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

impl StrictEncode for &str[src]

impl StrictEncode for String[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.

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.

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

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

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>.

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.

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

impl StrictEncode for bool[src]

impl StrictEncode for usize[src]

impl StrictEncode for f32[src]

impl StrictEncode for f64[src]

impl StrictEncode for Duration[src]

impl StrictEncode for NaiveDateTime[src]

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

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

impl<T> StrictEncode for Holder<T, BitcoinConsensus> where
    T: Encodable
[src]

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

Loading content...

Implementors

impl StrictEncode for RawAddr[src]

impl StrictEncode for RawUniformAddr[src]

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

Loading content...