Struct zcash_address::unified::Address
source · 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);
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
source§impl PartialEq for Address
impl PartialEq for Address
impl Eq for Address
impl StructuralPartialEq for Address
Auto Trait Implementations§
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