Trait handshakes::prelude::AddressEncoder [−][src]
pub trait AddressEncoder { type Address; type Error; type RecipientIdentifier: RecipientIdentifier; fn encode_address(
s: &Self::RecipientIdentifier
) -> Result<Self::Address, Self::Error>; fn decode_address(addr: &Self::Address) -> Self::RecipientIdentifier; fn string_to_address(s: &str) -> Result<Self::Address, Self::Error>; }
Expand description
An AddressEncoder encodes and decodes addresses. This struct is used by the Builder to decode addresses, and is associated with a Network object. It handles converting addresses to recipients and vice versa. It also contains a function that wraps a string in the appropriate address type.
This trait exists to maintain conceptual separation between the user-facing Address
and the
protocol-facing RecipientIdentifier
.
A Bitcoin encoder can be found in the bitcoin
crate.
Associated Types
A type representing the in-protocol recipient. This is usually different from the
Address type. The encoder converts between Strings
, Address
es, and
RecipientIdentifier
s
Required methods
fn encode_address(
s: &Self::RecipientIdentifier
) -> Result<Self::Address, Self::Error>
fn encode_address(
s: &Self::RecipientIdentifier
) -> Result<Self::Address, Self::Error>
Attempt to encode a RecipientIdentifier
as an Address
.
fn decode_address(addr: &Self::Address) -> Self::RecipientIdentifier
fn decode_address(addr: &Self::Address) -> Self::RecipientIdentifier
Decode a RecipientIdentifier
from an Address
. Addresses should be defined such that
this cannot fail.