pub struct ZcashAddress { /* private fields */ }
Expand description

A Zcash address.

Implementations§

source§

impl ZcashAddress

source

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().

source

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);
source

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.

source

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

source§

fn clone(&self) -> ZcashAddress

Returns a copy of the value. Read more
1.0.0 · source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
source§

impl Debug for ZcashAddress

source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
source§

impl Display for ZcashAddress

source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
source§

impl FromStr for ZcashAddress

source§

fn from_str(s: &str) -> Result<Self, Self::Err>

Attempts to parse the given string as a Zcash address.

§

type Err = ParseError

The associated error which can be returned from parsing.
source§

impl Hash for ZcashAddress

source§

fn hash<__H: Hasher>(&self, state: &mut __H)

Feeds this value into the given Hasher. Read more
1.3.0 · source§

fn hash_slice<H>(data: &[Self], state: &mut H)
where H: Hasher, Self: Sized,

Feeds a slice of this type into the given Hasher. Read more
source§

impl PartialEq for ZcashAddress

source§

fn eq(&self, other: &ZcashAddress) -> bool

This method tests for self and other values to be equal, and is used by ==.
1.0.0 · source§

fn ne(&self, other: &Rhs) -> bool

This method tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
source§

impl ToAddress for ZcashAddress

source§

fn from_sprout(net: Network, data: [u8; 64]) -> Self

source§

fn from_sapling(net: Network, data: [u8; 43]) -> Self

source§

fn from_unified(net: Network, data: Address) -> Self

source§

fn from_transparent_p2pkh(net: Network, data: [u8; 20]) -> Self

source§

fn from_transparent_p2sh(net: Network, data: [u8; 20]) -> Self

source§

fn from_tex(net: Network, data: [u8; 20]) -> Self

source§

impl Eq for ZcashAddress

source§

impl StructuralPartialEq for ZcashAddress

Auto Trait Implementations§

Blanket Implementations§

source§

impl<T> Any for T
where T: 'static + ?Sized,

source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
source§

impl<T> Borrow<T> for T
where T: ?Sized,

source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
source§

impl<T> From<T> for T

source§

fn from(t: T) -> T

Returns the argument unchanged.

source§

impl<T, U> Into<U> for T
where U: From<T>,

source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

source§

impl<T> Same for T

§

type Output = T

Should always be Self
source§

impl<T> ToOwned for T
where T: Clone,

§

type Owned = T

The resulting type after obtaining ownership.
source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
source§

impl<T> ToString for T
where T: Display + ?Sized,

source§

default fn to_string(&self) -> String

Converts the given value to a String. Read more
source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

§

type Error = Infallible

The type returned in the event of a conversion error.
source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.