Struct zcash_address::ZcashAddress
source · pub struct ZcashAddress { /* private fields */ }
Expand description
A Zcash address.
Implementations§
source§impl ZcashAddress
impl ZcashAddress
sourcepub fn encode(&self) -> String
pub fn encode(&self) -> String
Encodes this Zcash address in its canonical string representation.
This provides the encoded string representation of the address as defined by the
Zcash protocol specification and/or
ZIP 316. The Display
implementation can also
be used to produce this encoding using address.to_string()
.
sourcepub fn try_from_encoded(s: &str) -> Result<Self, ParseError>
pub fn try_from_encoded(s: &str) -> Result<Self, ParseError>
Attempts to parse the given string as a Zcash address.
This simply calls s.parse()
, leveraging the FromStr
implementation.
§Errors
-
If the parser can detect that the string must contain an address encoding used by Zcash,
ParseError::InvalidEncoding
will be returned if any subsequent part of that encoding is invalid. -
In all other cases,
ParseError::NotZcash
will be returned on failure.
§Examples
use zcash_address::ZcashAddress;
let encoded = "zs1z7rejlpsa98s2rrrfkwmaxu53e4ue0ulcrw0h4x5g8jl04tak0d3mm47vdtahatqrlkngh9sly";
let addr = ZcashAddress::try_from_encoded(&encoded);
assert_eq!(encoded.parse(), addr);
sourcepub fn convert<T: TryFromAddress>(self) -> Result<T, ConversionError<T::Error>>
pub fn convert<T: TryFromAddress>(self) -> Result<T, ConversionError<T::Error>>
Converts this address into another type.
convert
can convert into any type that implements the TryFromAddress
trait.
This enables ZcashAddress
to be used as a common parsing and serialization
interface for Zcash addresses, while delegating operations on those addresses
(such as constructing transactions) to downstream crates.
If you want to get the encoded string for this address, use the encode
method or the Display
implementation via address.to_string()
instead.
sourcepub fn convert_if_network<T: TryFromRawAddress>(
self,
net: Network
) -> Result<T, ConversionError<T::Error>>
pub fn convert_if_network<T: TryFromRawAddress>( self, net: Network ) -> Result<T, ConversionError<T::Error>>
Converts this address into another type, if it matches the expected network.
convert_if_network
can convert into any type that implements the
TryFromRawAddress
trait. This enables ZcashAddress
to be used as a common
parsing and serialization interface for Zcash addresses, while delegating
operations on those addresses (such as constructing transactions) to downstream
crates.
If you want to get the encoded string for this address, use the encode
method or the Display
implementation via address.to_string()
instead.
Trait Implementations§
source§impl Clone for ZcashAddress
impl Clone for ZcashAddress
source§fn clone(&self) -> ZcashAddress
fn clone(&self) -> ZcashAddress
1.0.0 · source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source
. Read moresource§impl Debug for ZcashAddress
impl Debug for ZcashAddress
source§impl Display for ZcashAddress
impl Display for ZcashAddress
source§impl FromStr for ZcashAddress
impl FromStr for ZcashAddress
source§impl Hash for ZcashAddress
impl Hash for ZcashAddress
source§impl PartialEq for ZcashAddress
impl PartialEq for ZcashAddress
source§fn eq(&self, other: &ZcashAddress) -> bool
fn eq(&self, other: &ZcashAddress) -> bool
self
and other
values to be equal, and is used
by ==
.