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.
Provided methods
fn strict_serialize(&self) -> Result<Vec<u8>, Error>
[src]
Expand description
Serializes data as a byte array using [strict_encode()
] function
Implementations on Foreign Types
impl StrictEncode for FlagVec
[src]
impl StrictEncode for FlagVec
[src]impl StrictEncode for u256
[src]
impl StrictEncode for u256
[src]impl StrictEncode for u512
[src]
impl StrictEncode for u512
[src]impl StrictEncode for u1024
[src]
impl StrictEncode for u1024
[src]impl<T> StrictEncode for Option<T> where
T: StrictEncode,
[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]
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]
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]
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]
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]
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]
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 &[u8]
[src]
impl StrictEncode for &[u8]
[src]impl StrictEncode for [u8; 16]
[src]
impl StrictEncode for [u8; 16]
[src]impl StrictEncode for [u8; 20]
[src]
impl StrictEncode for [u8; 20]
[src]impl StrictEncode for [u8; 32]
[src]
impl StrictEncode for [u8; 32]
[src]impl StrictEncode for [u8; 64]
[src]
impl StrictEncode for [u8; 64]
[src]impl<T> StrictEncode for Rc<T> where
T: StrictEncode,
[src]
impl<T> StrictEncode for Rc<T> where
T: StrictEncode,
[src]impl<T> StrictEncode for RefCell<T> where
T: StrictEncode,
[src]
impl<T> StrictEncode for RefCell<T> where
T: StrictEncode,
[src]impl<T> StrictEncode for Arc<T> where
T: StrictEncode,
[src]
impl<T> StrictEncode for Arc<T> where
T: StrictEncode,
[src]impl StrictEncode for &str
[src]
impl StrictEncode for &str
[src]impl StrictEncode for String
[src]
impl StrictEncode for String
[src]impl StrictEncode for bool
[src]
impl StrictEncode for bool
[src]impl StrictEncode for u8
[src]
impl StrictEncode for u8
[src]impl StrictEncode for i8
[src]
impl StrictEncode for i8
[src]impl StrictEncode for u16
[src]
impl StrictEncode for u16
[src]impl StrictEncode for i16
[src]
impl StrictEncode for i16
[src]impl StrictEncode for u32
[src]
impl StrictEncode for u32
[src]impl StrictEncode for i32
[src]
impl StrictEncode for i32
[src]impl StrictEncode for u64
[src]
impl StrictEncode for u64
[src]impl StrictEncode for i64
[src]
impl StrictEncode for i64
[src]impl StrictEncode for u128
[src]
impl StrictEncode for u128
[src]impl StrictEncode for i128
[src]
impl StrictEncode for i128
[src]impl StrictEncode for usize
[src]
impl StrictEncode for usize
[src]impl StrictEncode for f32
[src]
impl StrictEncode for f32
[src]impl StrictEncode for f64
[src]
impl StrictEncode for f64
[src]impl StrictEncode for Duration
[src]
impl StrictEncode for Duration
[src]impl StrictEncode for NaiveDateTime
[src]
impl StrictEncode for NaiveDateTime
[src]impl StrictEncode for DateTime<Utc>
[src]
impl StrictEncode for DateTime<Utc>
[src]impl<W> StrictEncode for Holder<W, Wrapped> where
W: Wrapper,
W::Inner: StrictEncode,
[src]
impl<W> StrictEncode for Holder<W, Wrapped> where
W: Wrapper,
W::Inner: StrictEncode,
[src]impl<H> StrictEncode for Holder<H, HashFixedBytes> where
H: Hash,
[src]
impl<H> StrictEncode for Holder<H, HashFixedBytes> where
H: Hash,
[src]impl<A> StrictEncode for Holder<A, UsingUniformAddr> where
A: Uniform,
[src]
impl<A> StrictEncode for Holder<A, UsingUniformAddr> where
A: Uniform,
[src]Implementors
impl StrictEncode for AddrFormat
[src]
impl StrictEncode for AddrFormat
[src]impl StrictEncode for Transport
[src]
impl StrictEncode for Transport
[src]impl StrictEncode for RawAddr
[src]
impl StrictEncode for RawAddr
[src]impl StrictEncode for RawUniformAddr
[src]
impl StrictEncode for RawUniformAddr
[src]impl<T> StrictEncode for T where
T: Strategy + Clone,
Holder<T, <T as Strategy>::Strategy>: StrictEncode,
[src]
impl<T> StrictEncode for T where
T: Strategy + Clone,
Holder<T, <T as Strategy>::Strategy>: StrictEncode,
[src]