pub struct Address(/* private fields */);Expand description
A struct representing a blockchain address. This struct provides various utility methods for working with addresses, including conversions from and to Bech32 string representations and byte arrays.
§Serialization
This struct is serializable with the serde crate.
§Cloning
Cloning is supported.
§Debugging
Debug printouts are supported.
§Examples
Basic usage:
let address = Address::from_bech32_string("erd1qqqqqqqqqqqqqpgq7ykazrzd905zvnlr88dpfw06677lxe9w0n4suz00uh").unwrap();
let bech32 = address.to_bech32_string().unwrap();
assert_eq!(bech32, "erd1qqqqqqqqqqqqqpgq7ykazrzd905zvnlr88dpfw06677lxe9w0n4suz00uh");Implementations§
Source§impl Address
The Address struct provides an abstraction over a blockchain address,
with various utility methods for working with addresses.
impl Address
The Address struct provides an abstraction over a blockchain address,
with various utility methods for working with addresses.
Sourcepub fn from_bech32_string(bech32: &str) -> Result<Address, DataError>
pub fn from_bech32_string(bech32: &str) -> Result<Address, DataError>
Creates an Address instance from a Bech32 string representation.
§Parameters
bech32: The Bech32 string representation of the address.
§Returns
- An
Ok(Address)instance if the conversion is successful. - An
Err(DataError)if the Bech32 string is invalid.
§Example
let address = Address::from_bech32_string("erd1qqqqqqqqqqqqqpgq7ykazrzd905zvnlr88dpfw06677lxe9w0n4suz00uh").unwrap();Sourcepub fn from_bytes(bytes: [u8; 32]) -> Address
pub fn from_bytes(bytes: [u8; 32]) -> Address
Sourcepub fn to_bech32_string(&self) -> Result<String, DataError>
pub fn to_bech32_string(&self) -> Result<String, DataError>
Trait Implementations§
Source§impl<'a> Deserialize<'a> for Address
impl<'a> Deserialize<'a> for Address
Source§fn deserialize<D>(deserializer: D) -> Result<Self, D::Error>where
D: Deserializer<'a>,
fn deserialize<D>(deserializer: D) -> Result<Self, D::Error>where
D: Deserializer<'a>,
Deserialize this value from the given Serde deserializer. Read more
Source§impl From<&Address> for Address
impl From<&Address> for Address
Source§fn from(value: &SDKAddress) -> Self
fn from(value: &SDKAddress) -> Self
Converts to this type from the input type.
Source§impl From<&Address> for AddressValue
impl From<&Address> for AddressValue
Source§impl From<Address> for Address
impl From<Address> for Address
Source§fn from(value: SDKAddress) -> Self
fn from(value: SDKAddress) -> Self
Converts to this type from the input type.
Source§impl ManagedConvertible<ManagedAddress<VMHooksApi<StaticApiBackend>>> for Address
impl ManagedConvertible<ManagedAddress<VMHooksApi<StaticApiBackend>>> for Address
Source§fn to_managed(&self) -> ManagedAddress<StaticApi>
fn to_managed(&self) -> ManagedAddress<StaticApi>
Converts the native Rust type to the specified managed type.
Source§impl NativeConvertible for Address
impl NativeConvertible for Address
Source§impl TopDecode for Address
impl TopDecode for Address
Source§fn top_decode<I>(input: I) -> Result<Self, DecodeError>where
I: TopDecodeInput,
fn top_decode<I>(input: I) -> Result<Self, DecodeError>where
I: TopDecodeInput,
Attempt to deserialize the value from input.
Source§fn top_decode_or_handle_err<I, H>(
input: I,
h: H,
) -> Result<Self, <H as DecodeErrorHandler>::HandledErr>where
I: TopDecodeInput,
H: DecodeErrorHandler,
fn top_decode_or_handle_err<I, H>(
input: I,
h: H,
) -> Result<Self, <H as DecodeErrorHandler>::HandledErr>where
I: TopDecodeInput,
H: DecodeErrorHandler,
Version of
top_decode that can handle errors as soon as they occur.
For instance it can exit immediately and make sure that if it returns, it is a success.
By not deferring error handling, this can lead to somewhat smaller bytecode.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> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> InterpretableFrom<&T> for Twhere
T: Clone,
impl<T> InterpretableFrom<&T> for Twhere
T: Clone,
fn interpret_from(from: &T, _context: &InterpreterContext) -> T
Source§impl<T> InterpretableFrom<T> for T
impl<T> InterpretableFrom<T> for T
fn interpret_from(from: T, _context: &InterpreterContext) -> T
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 moreSource§impl<T> ReconstructableFrom<&T> for Twhere
T: Clone,
impl<T> ReconstructableFrom<&T> for Twhere
T: Clone,
fn reconstruct_from(from: &T, _builder: &ReconstructorContext) -> T
Source§impl<T> ReconstructableFrom<T> for T
impl<T> ReconstructableFrom<T> for T
fn reconstruct_from(from: T, _builder: &ReconstructorContext) -> T
Source§impl<T> TopDecodeMulti for Twhere
T: TopDecode,
impl<T> TopDecodeMulti for Twhere
T: TopDecode,
Source§const IS_SINGLE_VALUE: bool = true
const IS_SINGLE_VALUE: bool = true
Used to optimize single value loading of endpoint arguments.