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: NetworkType,
) -> Result<T, ConversionError<T::Error>>
pub fn convert_if_network<T: TryFromRawAddress>( self, net: NetworkType, ) -> 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.
Sourcepub fn convert_with<T, C: Converter<T>>(
self,
converter: C,
) -> Result<T, ConversionError<C::Error>>
pub fn convert_with<T, C: Converter<T>>( self, converter: C, ) -> Result<T, ConversionError<C::Error>>
Converts this address into another type using the specified converter.
convert
can convert into any type T
for which an implementation of the Converter<T>
trait exists. This enables conversion of ZcashAddress
values into other types to rely
on additional context.
Sourcepub fn can_receive_as(&self, pool_type: PoolType) -> bool
pub fn can_receive_as(&self, pool_type: PoolType) -> bool
Returns whether this address has the ability to receive transfers of the given pool type.
Sourcepub fn can_receive_memo(&self) -> bool
pub fn can_receive_memo(&self) -> bool
Returns whether this address can receive a memo.
Sourcepub fn matches_receiver(&self, receiver: &Receiver) -> bool
pub fn matches_receiver(&self, receiver: &Receiver) -> bool
Returns whether or not this address contains or corresponds to the given unified address receiver.
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§impl ToAddress for ZcashAddress
impl ToAddress for ZcashAddress
fn from_sprout(net: NetworkType, data: [u8; 64]) -> Self
fn from_sapling(net: NetworkType, data: [u8; 43]) -> Self
fn from_unified(net: NetworkType, data: Address) -> Self
fn from_transparent_p2pkh(net: NetworkType, data: [u8; 20]) -> Self
fn from_transparent_p2sh(net: NetworkType, data: [u8; 20]) -> Self
fn from_tex(net: NetworkType, data: [u8; 20]) -> Self
impl Eq for ZcashAddress
impl StructuralPartialEq for ZcashAddress
Auto Trait Implementations§
impl Freeze for ZcashAddress
impl RefUnwindSafe for ZcashAddress
impl Send for ZcashAddress
impl Sync for ZcashAddress
impl Unpin for ZcashAddress
impl UnwindSafe for ZcashAddress
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
self
into a Left
variant of Either<Self, Self>
if into_left
is true
.
Converts self
into a Right
variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
self
into a Left
variant of Either<Self, Self>
if into_left(&self)
returns true
.
Converts self
into a Right
variant of Either<Self, Self>
otherwise. Read more