[][src]Trait lnpbp::strict_encoding::StrictEncode

pub trait StrictEncode {
    type Error: Error + From<Error>;
    fn strict_encode<E: Write>(&self, e: E) -> Result<usize, Self::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.

Associated Types

type Error: Error + From<Error>

Implementation-dependent error type

Loading content...

Required methods

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

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

Loading content...

Implementations on Foreign Types

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

type Error = <T::Inner as StrictEncode>::Error

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

type Error = Error

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

type Error = Error

impl StrictEncode for bool[src]

type Error = Error

impl StrictEncode for usize[src]

type Error = Error

impl StrictEncode for f32[src]

type Error = Error

impl StrictEncode for f64[src]

type Error = Error

impl<'_> StrictEncode for &'_ [u8][src]

type Error = Error

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

type Error = Error

impl<'_> StrictEncode for &'_ str[src]

type Error = Error

impl StrictEncode for String[src]

type Error = Error

impl<T> StrictEncode for Option<T> where
    T: StrictEncode,
    T::Error: From<Error>, 
[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.

type Error = T::Error

impl<T> StrictEncode for Vec<T> where
    T: StrictEncode,
    T::Error: From<Error>, 
[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.

type Error = T::Error

impl<T> StrictEncode for HashSet<T> where
    T: StrictEncode + Eq + Ord + Hash + Debug,
    T::Error: From<Error>, 
[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

type Error = T::Error

impl<T> StrictEncode for BTreeSet<T> where
    T: StrictEncode + Eq + Ord + Debug,
    T::Error: From<Error>, 
[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

type Error = T::Error

impl<T> StrictEncode for HashMap<usize, T> where
    T: StrictEncode + Clone,
    T::Error: From<Error>, 
[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>.

type Error = T::Error

impl<K, V> StrictEncode for BTreeMap<K, V> where
    K: StrictEncode + Ord + Clone,
    V: StrictEncode + Clone,
    K::Error: From<Error>,
    V::Error: From<Error> + From<K::Error>, 
[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.

type Error = V::Error

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

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

type Error = V::Error

impl StrictEncode for Script[src]

type Error = Error

impl StrictEncode for SecretKey[src]

type Error = Error

impl StrictEncode for PublicKey[src]

type Error = Error

impl StrictEncode for Signature[src]

type Error = Error

impl StrictEncode for PublicKey[src]

type Error = Error

impl StrictEncode for Network[src]

type Error = Error

impl StrictEncode for ChildNumber[src]

type Error = Error

impl StrictEncode for DerivationPath[src]

type Error = Error

impl StrictEncode for ChainCode[src]

type Error = Error

impl StrictEncode for Fingerprint[src]

type Error = Error

impl StrictEncode for ExtendedPubKey[src]

type Error = Error

impl StrictEncode for ExtendedPrivKey[src]

type Error = Error

Loading content...

Implementors

impl StrictEncode for AssetLayer[src]

type Error = Error

impl StrictEncode for AssetSystem[src]

type Error = Error

impl StrictEncode for Chain[src]

type Error = Error

impl StrictEncode for ChainFormat[src]

type Error = Error

impl StrictEncode for P2pNetworkId[src]

type Error = Error

impl StrictEncode for ScriptEncodeData[src]

type Error = Error

impl StrictEncode for OutpointReveal[src]

type Error = Error

impl StrictEncode for AssetParams[src]

type Error = Error

impl StrictEncode for ChainParams[src]

type Error = Error

impl StrictEncode for Proof[src]

type Error = Error

impl StrictEncode for ShortId[src]

type Error = Error

impl StrictEncode for FlagVec[src]

type Error = Error

impl StrictEncode for MultimsgCommitment[src]

type Error = Error

impl StrictEncode for MultimsgCommitmentItem[src]

type Error = Error

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

type Error = <Holder<T, T::Strategy> as StrictEncode>::Error

Loading content...