Skip to main content

Address

Struct Address 

Source
pub struct Address { /* private fields */ }
Expand description

A TON account address: a workchain id and a 256-bit account id.

Parses both the raw workchain:hex form and the user-friendly base64 form. The address carries no balance or state.

Two addresses are equal when they name the same account. The user-friendly form also carries a bounceable and a test-only flag, which say how a message to the account should be sent and which network it belongs to rather than which account it is, so they are readable but do not enter into equality. The raw form carries neither, and an address parsed from it reports the defaults: bounceable, and not test-only.

Implementations§

Source§

impl Address

Source

pub fn parse(s: &str) -> Result<Self, Error>

Parses an address from a string.

Accepts the raw form, for example -1:3333...3333, and the user-friendly base64 form, for example Ef8z.... A raw address is a workchain, a colon, and 64 hex digits. A user-friendly address is 36 base64 bytes whose CRC16 checksum is verified.

§Errors

Returns Error::Address if the string is not a valid address in either form, or if a user-friendly address fails its checksum.

§Examples
use ton_net::Address;
let a = Address::parse(
    "-1:3333333333333333333333333333333333333333333333333333333333333333",
)?;
assert_eq!(a.workchain(), -1);
Source

pub fn workchain(&self) -> i32

Returns the workchain id.

Source

pub fn account_id(&self) -> &[u8; 32]

Returns the 32-byte account id.

Source

pub fn is_bounceable(&self) -> bool

Whether a failed message to this address should be returned to its sender.

A hint about sending, not part of the account’s identity. True for an address parsed from the raw form, which does not carry the flag.

Source

pub fn is_test_only(&self) -> bool

Whether the address was written for a test network.

Which network a client is on is decided by its Config, not by an address, so this is not enforced anywhere: a test-only address read against mainnet gets a correct answer about a mainnet account, which is almost certainly not the account the caller meant. A caller that cares checks this.

Trait Implementations§

Source§

impl Clone for Address

Source§

fn clone(&self) -> Self

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

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

Performs copy-assignment from source. Read more
Source§

impl Debug for Address

Source§

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

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

impl Eq for Address

Source§

impl Hash for Address

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 Address

Source§

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

Equal when they name the same account. The sending hints are not the account.

1.0.0 (const: unstable) · Source§

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

Inequality operator !=. Read more

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> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. 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

Source§

type Output = T

Should always be Self
Source§

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

Source§

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, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = !

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

fn try_from(value: U) -> Result<T, !>

Performs the conversion.
Source§

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

Source§

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.