Trait strict_encoding::StrictEncode 
source · [−]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 commit_verify module.
Required Methods
Encode with the given std::io::Write instance; must return result
with either amount of bytes encoded – or implementation-specific
error type.
Provided Methods
Serializes data as a byte array using StrictEncode::strict_encode
function
Implementations on Foreign Types
sourceimpl StrictEncode for FlagVec
 
impl StrictEncode for FlagVec
sourceimpl StrictEncode for u256
 
impl StrictEncode for u256
sourceimpl StrictEncode for u512
 
impl StrictEncode for u512
sourceimpl StrictEncode for u1024
 
impl StrictEncode for u1024
sourceimpl StrictEncode for LeafVersion
 
impl StrictEncode for LeafVersion
sourceimpl StrictEncode for FutureLeafVersion
 
impl StrictEncode for FutureLeafVersion
sourceimpl StrictEncode for TaprootMerkleBranch
 
impl StrictEncode for TaprootMerkleBranch
sourceimpl StrictEncode for SecretKey
 
impl StrictEncode for SecretKey
sourceimpl StrictEncode for TweakedKeyPair
 
impl StrictEncode for TweakedKeyPair
sourceimpl StrictEncode for KeyPair
 
impl StrictEncode for KeyPair
sourceimpl StrictEncode for PublicKey
 
impl StrictEncode for PublicKey
sourceimpl StrictEncode for XOnlyPublicKey
 
impl StrictEncode for XOnlyPublicKey
sourceimpl StrictEncode for TweakedPublicKey
 
impl StrictEncode for TweakedPublicKey
sourceimpl StrictEncode for Signature
 
impl StrictEncode for Signature
sourceimpl StrictEncode for Signature
 
impl StrictEncode for Signature
sourceimpl StrictEncode for PsbtSighashType
 
impl StrictEncode for PsbtSighashType
sourceimpl StrictEncode for EcdsaSighashType
 
impl StrictEncode for EcdsaSighashType
sourceimpl StrictEncode for SchnorrSighashType
 
impl StrictEncode for SchnorrSighashType
sourceimpl StrictEncode for EcdsaSig
 
impl StrictEncode for EcdsaSig
sourceimpl StrictEncode for SchnorrSig
 
impl StrictEncode for SchnorrSig
sourceimpl StrictEncode for Payload
 
impl StrictEncode for Payload
sourceimpl StrictEncode for Address
 
impl StrictEncode for Address
sourceimpl StrictEncode for Amount
 
impl StrictEncode for Amount
sourceimpl StrictEncode for Script
 
impl StrictEncode for Script
sourceimpl StrictEncode for ControlBlock
 
impl StrictEncode for ControlBlock
sourceimpl StrictEncode for ScriptLeaf
 
impl StrictEncode for ScriptLeaf
sourceimpl StrictEncode for Network
 
impl StrictEncode for Network
sourceimpl StrictEncode for ChildNumber
 
impl StrictEncode for ChildNumber
sourceimpl StrictEncode for DerivationPath
 
impl StrictEncode for DerivationPath
sourceimpl StrictEncode for ChainCode
 
impl StrictEncode for ChainCode
sourceimpl StrictEncode for Fingerprint
 
impl StrictEncode for Fingerprint
sourceimpl StrictEncode for ExtendedPubKey
 
impl StrictEncode for ExtendedPubKey
sourceimpl StrictEncode for ExtendedPrivKey
 
impl StrictEncode for ExtendedPrivKey
sourceimpl StrictEncode for Key
 
impl StrictEncode for Key
sourceimpl StrictEncode for Pair
 
impl StrictEncode for Pair
sourceimpl StrictEncode for ProprietaryKey
 
impl StrictEncode for ProprietaryKey
sourceimpl StrictEncode for TapTree
 
impl StrictEncode for TapTree
sourceimpl StrictEncode for &Script
 
impl StrictEncode for &Script
sourceimpl<T> StrictEncode for Range<T> where
    T: StrictEncode, 
 
impl<T> StrictEncode for Range<T> where
    T: StrictEncode, 
In terms of strict encoding, ranges are encoded as a tuples of two values: start and end.
sourceimpl<T> StrictEncode for RangeInclusive<T> where
    T: StrictEncode, 
 
impl<T> StrictEncode for RangeInclusive<T> where
    T: StrictEncode, 
In terms of strict encoding, inclusive ranges are encoded as a tuples of two values: start and end.
sourceimpl<T> StrictEncode for RangeFrom<T> where
    T: StrictEncode, 
 
impl<T> StrictEncode for RangeFrom<T> where
    T: StrictEncode, 
In terms of strict encoding, partial ranges are encoded as a single value.
sourceimpl<T> StrictEncode for RangeTo<T> where
    T: StrictEncode, 
 
impl<T> StrictEncode for RangeTo<T> where
    T: StrictEncode, 
In terms of strict encoding, partial ranges are encoded as a single value.
sourceimpl<T> StrictEncode for RangeToInclusive<T> where
    T: StrictEncode, 
 
impl<T> StrictEncode for RangeToInclusive<T> where
    T: StrictEncode, 
In terms of strict encoding, partial ranges are encoded as a single value.
sourceimpl<T> StrictEncode for Option<T> where
    T: StrictEncode, 
 
impl<T> StrictEncode for Option<T> where
    T: StrictEncode, 
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.
sourceimpl<T> StrictEncode for [T] where
    T: StrictEncode, 
 
impl<T> StrictEncode for [T] where
    T: StrictEncode, 
In terms of strict encoding, a slice 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.
sourceimpl<T> StrictEncode for Vec<T> where
    T: StrictEncode, 
 
impl<T> StrictEncode for Vec<T> where
    T: StrictEncode, 
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.
sourceimpl<T> StrictEncode for HashSet<T> where
    T: StrictEncode + Eq + Ord + Hash + Debug, 
 
impl<T> StrictEncode for HashSet<T> where
    T: StrictEncode + Eq + Ord + Hash + Debug, 
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
sourceimpl<T> StrictEncode for BTreeSet<T> where
    T: StrictEncode + Eq + Ord + Debug, 
 
impl<T> StrictEncode for BTreeSet<T> where
    T: StrictEncode + Eq + Ord + Debug, 
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
sourceimpl<T> StrictEncode for HashMap<usize, T> where
    T: StrictEncode + Clone, 
 
impl<T> StrictEncode for HashMap<usize, T> where
    T: StrictEncode + Clone, 
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>.
sourceimpl<K, V> StrictEncode for BTreeMap<K, V> where
    K: StrictEncode + Ord + Clone,
    V: StrictEncode + Clone, 
 
impl<K, V> StrictEncode for BTreeMap<K, V> where
    K: StrictEncode + Ord + Clone,
    V: StrictEncode + Clone, 
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.
sourceimpl<K, V> StrictEncode for (K, V) where
    K: StrictEncode + Clone,
    V: StrictEncode + Clone, 
 
impl<K, V> StrictEncode for (K, V) where
    K: StrictEncode + Clone,
    V: StrictEncode + Clone, 
Two-component tuples are encoded as they were fields in the parent data structure