pub struct Address(/* private fields */);Expand description
A TRON network address (0x41 prefix + 20-byte body).
Implementations§
Source§impl Address
impl Address
Sourcepub fn from_bytes(bytes: [u8; 21]) -> Result<Self, AddressError>
pub fn from_bytes(bytes: [u8; 21]) -> Result<Self, AddressError>
Construct from the full 21-byte representation, validating the prefix.
Sourcepub fn from_slice(slice: &[u8]) -> Result<Self, AddressError>
pub fn from_slice(slice: &[u8]) -> Result<Self, AddressError>
Construct from a 21-byte slice, validating length and prefix.
Sourcepub fn from_evm_bytes(evm: [u8; 20]) -> Self
pub fn from_evm_bytes(evm: [u8; 20]) -> Self
Construct from the 20-byte EVM-style body, prepending the 0x41 prefix.
Sourcepub fn from_public_key(key: &VerifyingKey) -> Self
pub fn from_public_key(key: &VerifyingKey) -> Self
Derive the address from a secp256k1 public key.
address = 0x41 || keccak256(uncompressed_pubkey[1..])[12..]
Sourcepub fn from_base58(s: &str) -> Result<Self, AddressError>
pub fn from_base58(s: &str) -> Result<Self, AddressError>
Parse a base58check (T...) address string.
Sourcepub fn from_hex(s: &str) -> Result<Self, AddressError>
pub fn from_hex(s: &str) -> Result<Self, AddressError>
Parse a hex address string with an optional 0x prefix.
The encoded bytes must include the TRON 0x41 address prefix.
Sourcepub fn as_bytes(&self) -> &[u8; 21]
pub fn as_bytes(&self) -> &[u8; 21]
The full 21-byte representation, including the 0x41 prefix.
Sourcepub fn as_evm_bytes(&self) -> &[u8; 20]
pub fn as_evm_bytes(&self) -> &[u8; 20]
The 20-byte EVM-style body (prefix stripped). Use this when bridging to
alloy / ABI encoding.
Trait Implementations§
impl Copy for Address
Source§impl<'de> Deserialize<'de> for Address
impl<'de> Deserialize<'de> for Address
Source§fn deserialize<D: Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error>
fn deserialize<D: Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error>
impl Eq for Address
Source§impl FromStr for Address
impl FromStr for Address
Source§fn from_str(s: &str) -> Result<Self, Self::Err>
fn from_str(s: &str) -> Result<Self, Self::Err>
Accepts either a base58check (T...) or a hex (41... / 0x41...)
address. Hex is detected when every character is a hex digit and the
string is the right length for a 21-byte address.
Source§type Err = AddressError
type Err = AddressError
Source§impl Ord for Address
impl Ord for Address
1.21.0 (const: unstable) · Source§fn max(self, other: Self) -> Selfwhere
Self: Sized,
fn max(self, other: Self) -> Selfwhere
Self: Sized,
Source§impl PartialOrd for Address
impl PartialOrd 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 UnsafeUnpin 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
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> DeserializeOwned for Twhere
T: for<'de> Deserialize<'de>,
Source§impl<T> ToHex for T
impl<T> ToHex for T
Source§fn encode_hex<U>(&self) -> Uwhere
U: FromIterator<char>,
fn encode_hex<U>(&self) -> Uwhere
U: FromIterator<char>,
use ToHexExt instead
self into the result.
Lower case letters are used (e.g. f9b4ca).Source§fn encode_hex_upper<U>(&self) -> Uwhere
U: FromIterator<char>,
fn encode_hex_upper<U>(&self) -> Uwhere
U: FromIterator<char>,
use ToHexExt instead
self into the result.
Upper case letters are used (e.g. F9B4CA).Source§impl<T> ToHex for T
impl<T> ToHex for T
Source§fn encode_hex<U>(&self) -> Uwhere
U: FromIterator<char>,
fn encode_hex<U>(&self) -> Uwhere
U: FromIterator<char>,
self into the result. Lower case
letters are used (e.g. f9b4ca)Source§fn encode_hex_upper<U>(&self) -> Uwhere
U: FromIterator<char>,
fn encode_hex_upper<U>(&self) -> Uwhere
U: FromIterator<char>,
self into the result. Upper case
letters are used (e.g. F9B4CA)Source§impl<T> ToHexExt for T
impl<T> ToHexExt for T
Source§fn encode_hex(&self) -> String
fn encode_hex(&self) -> String
self into the result.
Lower case letters are used (e.g. f9b4ca).Source§fn encode_hex_upper(&self) -> String
fn encode_hex_upper(&self) -> String
self into the result.
Upper case letters are used (e.g. F9B4CA).Source§fn encode_hex_with_prefix(&self) -> String
fn encode_hex_with_prefix(&self) -> String
self into the result with prefix 0x.
Lower case letters are used (e.g. 0xf9b4ca).Source§fn encode_hex_upper_with_prefix(&self) -> String
fn encode_hex_upper_with_prefix(&self) -> String
self into the result with prefix 0X.
Upper case letters are used (e.g. 0xF9B4CA).Layout§
Note: Most layout information is completely unstable and may even differ between compilations. The only exception is types with certain repr(...) attributes. Please see the Rust Reference's “Type Layout” chapter for details on type layout guarantees.
Size: 21 bytes