pub trait Encoding: SealedContainer {
// Provided methods
fn try_from_items(items: Vec<Self::Item>) -> Result<Self, ParseError> { ... }
fn decode(s: &str) -> Result<(NetworkType, Self), ParseError> { ... }
fn encode(&self, network: &NetworkType) -> String { ... }
}
Expand description
Trait providing common encoding and decoding logic for Unified containers.
Provided Methods§
Sourcefn try_from_items(items: Vec<Self::Item>) -> Result<Self, ParseError>
fn try_from_items(items: Vec<Self::Item>) -> Result<Self, ParseError>
Constructs a value of a unified container type from a vector of container items, sorted according to typecode as specified in ZIP 316.
This function will return an error in the case that the following ZIP 316 invariants concerning the composition of a unified container are violated:
- the item list may not contain two items having the same typecode
- the item list may not contain only transparent items (or no items)
- the item list may not contain both P2PKH and P2SH items.
Sourcefn decode(s: &str) -> Result<(NetworkType, Self), ParseError>
fn decode(s: &str) -> Result<(NetworkType, Self), ParseError>
Decodes a unified container from its string representation, preserving the order of its components so that it correctly obeys round-trip serialization invariants.
Dyn Compatibility§
This trait is not dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.