pub trait Encoding: SealedContainer {
    // Provided methods
    fn try_from_items(items: Vec<Self::Item>) -> Result<Self, ParseError> { ... }
    fn decode(s: &str) -> Result<(Network, Self), ParseError> { ... }
    fn encode(&self, network: &Network) -> String { ... }
}
Expand description

Trait providing common encoding and decoding logic for Unified containers.

Provided Methods§

source

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

fn decode(s: &str) -> Result<(Network, 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.

source

fn encode(&self, network: &Network) -> String

Encodes the contents of the unified container to its string representation using the correct constants for the specified network, preserving the ordering of the contained items such that it correctly obeys round-trip serialization invariants.

Object Safety§

This trait is not object safe.

Implementors§