Struct zcash_address::ZcashAddress
source · [−]pub struct ZcashAddress { /* private fields */ }
Expand description
A Zcash address.
Implementations
sourceimpl 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: FromAddress>(self) -> Result<T, UnsupportedAddress>
pub fn convert<T: FromAddress>(self) -> Result<T, UnsupportedAddress>
Converts this address into another type.
convert
can convert into any type that implements the FromAddress
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
sourceimpl Clone for ZcashAddress
impl Clone for ZcashAddress
sourcefn clone(&self) -> ZcashAddress
fn clone(&self) -> ZcashAddress
Returns a copy of the value. Read more
1.0.0 · sourcefn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from source
. Read more
sourceimpl Debug for ZcashAddress
impl Debug for ZcashAddress
sourceimpl Display for ZcashAddress
impl Display for ZcashAddress
sourceimpl FromStr for ZcashAddress
impl FromStr for ZcashAddress
sourceimpl Hash for ZcashAddress
impl Hash for ZcashAddress
sourceimpl PartialEq<ZcashAddress> for ZcashAddress
impl PartialEq<ZcashAddress> for ZcashAddress
sourcefn eq(&self, other: &ZcashAddress) -> bool
fn eq(&self, other: &ZcashAddress) -> bool
This method tests for self
and other
values to be equal, and is used
by ==
. Read more
sourcefn ne(&self, other: &ZcashAddress) -> bool
fn ne(&self, other: &ZcashAddress) -> bool
This method tests for !=
.
sourceimpl ToAddress for ZcashAddress
impl ToAddress for ZcashAddress
fn from_sprout(net: Network, data: [u8; 64]) -> Self
fn from_sapling(net: Network, data: [u8; 43]) -> Self
fn from_unified(net: Network, data: Address) -> Self
fn from_transparent_p2pkh(net: Network, data: [u8; 20]) -> Self
fn from_transparent_p2sh(net: Network, data: [u8; 20]) -> Self
impl Eq for ZcashAddress
impl StructuralEq for ZcashAddress
impl StructuralPartialEq for ZcashAddress
Auto Trait Implementations
impl RefUnwindSafe for ZcashAddress
impl Send for ZcashAddress
impl Sync for ZcashAddress
impl Unpin for ZcashAddress
impl UnwindSafe for ZcashAddress
Blanket Implementations
sourceimpl<T> BorrowMut<T> for T where
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
const: unstable · sourcefn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
sourceimpl<T> ToOwned for T where
T: Clone,
impl<T> ToOwned for T where
T: Clone,
type Owned = T
type Owned = T
The resulting type after obtaining ownership.
sourcefn clone_into(&self, target: &mut T)
fn clone_into(&self, target: &mut T)
toowned_clone_into
)Uses borrowed data to replace owned data, usually by cloning. Read more