pub struct Address(/* private fields */);
Expand description
A Unified Address.
§Examples
use zcash_address::{
unified::{self, Container, Encoding},
ConversionError, TryFromRawAddress, ZcashAddress,
};
let example_ua: &str = address_from_user();
// We can parse this directly as a `unified::Address`:
let (network, ua) = unified::Address::decode(example_ua)?;
// Or we can parse via `ZcashAddress` (which you should do):
struct MyUnifiedAddress(unified::Address);
impl TryFromRawAddress for MyUnifiedAddress {
// In this example we aren't checking the validity of the
// inner Unified Address, but your code should do so!
type Error = Infallible;
fn try_from_raw_unified(ua: unified::Address) -> Result<Self, ConversionError<Self::Error>> {
Ok(MyUnifiedAddress(ua))
}
}
let addr: ZcashAddress = example_ua.parse()?;
let parsed = addr.convert_if_network::<MyUnifiedAddress>(network)?;
assert_eq!(parsed.0, ua);
// We can obtain the receivers for the UA in preference order
// (the order in which wallets should prefer to use them):
let receivers: Vec<unified::Receiver> = ua.items();
// And we can create the UA from a list of receivers:
let new_ua = unified::Address::try_from_items(receivers)?;
assert_eq!(new_ua, ua);
Implementations§
Source§impl Address
impl Address
Sourcepub fn has_receiver_of_type(&self, pool_type: PoolType) -> bool
pub fn has_receiver_of_type(&self, pool_type: PoolType) -> bool
Returns whether this address has the ability to receive transfers of the given pool type.
Sourcepub fn contains_receiver(&self, receiver: &Receiver) -> bool
pub fn contains_receiver(&self, receiver: &Receiver) -> bool
Returns whether this address contains the given receiver.
Sourcepub fn can_receive_memo(&self) -> bool
pub fn can_receive_memo(&self) -> bool
Returns whether this address can receive a memo.
Trait Implementations§
Source§impl Container for Address
impl Container for Address
Source§fn items_as_parsed(&self) -> &[Receiver]
fn items_as_parsed(&self) -> &[Receiver]
Returns the items in the order they were parsed from the string encoding. Read more
Source§impl Encoding for Address
impl Encoding for Address
Source§fn try_from_items(items: Vec<Self::Item>) -> Result<Self, ParseError>
fn try_from_items(items: Vec<Self::Item>) -> Result<Self, ParseError>
Constructs a value of a unified container type from a vector
of container items, sorted according to typecode as specified
in ZIP 316. Read more
impl Eq for Address
impl StructuralPartialEq for Address
Auto Trait Implementations§
impl Freeze for Address
impl RefUnwindSafe for Address
impl Send for Address
impl Sync for Address
impl Unpin for Address
impl UnwindSafe for Address
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
Mutably borrows from an owned value. Read more
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>
Converts
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>
Converts
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