alloy_primitives

Struct Address

Source
#[repr(transparent)]
pub struct Address(pub FixedBytes<20>);
Expand description

An Ethereum address, 20 bytes in length.

This type is separate from B160 / FixedBytes<20> and is declared with the wrap_fixed_bytes! macro. This allows us to implement address-specific functionality.

The main difference with the generic FixedBytes implementation is that Display formats the address using its EIP-55 checksum (to_checksum). Use Debug to display the raw bytes without the checksum.

§Examples

Parsing and formatting:

use alloy_primitives::{address, Address};

let checksummed = "0xd8dA6BF26964aF9D7eEd9e03E53415D37aA96045";
let expected = address!("d8da6bf26964af9d7eed9e03e53415d37aa96045");
let address = Address::parse_checksummed(checksummed, None).expect("valid checksum");
assert_eq!(address, expected);

// Format the address with the checksum
assert_eq!(address.to_string(), checksummed);
assert_eq!(address.to_checksum(None), checksummed);

// Format the compressed checksummed address
assert_eq!(format!("{address:#}"), "0xd8dA…6045");

// Format the address without the checksum
assert_eq!(format!("{address:?}"), "0xd8da6bf26964af9d7eed9e03e53415d37aa96045");

Tuple Fields§

§0: FixedBytes<20>

Implementations§

Source§

impl Address

Source

pub const ZERO: Self = _

Array of Zero bytes.

Source

pub const fn new(bytes: [u8; 20]) -> Self

Wraps the given byte array in this type.

Source

pub const fn with_last_byte(x: u8) -> Self

Creates a new byte array with the last byte set to x.

Source

pub const fn repeat_byte(byte: u8) -> Self

Creates a new byte array where all bytes are set to byte.

Source

pub const fn len_bytes() -> usize

Returns the size of this array in bytes.

Source

pub fn random() -> Self

Available on crate feature getrandom only.

Instantiates a new fixed byte array with cryptographically random content.

§Panics

Panics if the underlying call to getrandom_uninit fails.

Source

pub fn try_random() -> Result<Self, Error>

Available on crate feature getrandom only.

Tries to create a new fixed byte array with cryptographically random content.

§Errors

This function only propagates the error from the underlying call to getrandom_uninit.

Source

pub fn randomize(&mut self)

Available on crate feature getrandom only.

Fills this fixed byte array with cryptographically random content.

§Panics

Panics if the underlying call to getrandom_uninit fails.

Source

pub fn try_randomize(&mut self) -> Result<(), Error>

Available on crate feature getrandom only.

Tries to fill this fixed byte array with cryptographically random content.

§Errors

This function only propagates the error from the underlying call to getrandom_uninit.

Source

pub fn random_with<R: Rng + ?Sized>(rng: &mut R) -> Self

Available on crate feature rand only.

Creates a new fixed byte array with the given random number generator.

Source

pub fn randomize_with<R: Rng + ?Sized>(&mut self, rng: &mut R)

Available on crate feature rand only.

Fills this fixed byte array with the given random number generator.

Source

pub fn from_slice(src: &[u8]) -> Self

Create a new byte array from the given slice src.

For a fallible version, use the TryFrom<&[u8]> implementation.

§Note

The given bytes are interpreted in big endian order.

§Panics

If the length of src and the number of bytes in Self do not match.

Source

pub fn left_padding_from(value: &[u8]) -> Self

Create a new byte array from the given slice src, left-padding it with zeroes if necessary.

§Note

The given bytes are interpreted in big endian order.

§Panics

Panics if src.len() > N.

Source

pub fn right_padding_from(value: &[u8]) -> Self

Create a new byte array from the given slice src, right-padding it with zeroes if necessary.

§Note

The given bytes are interpreted in big endian order.

§Panics

Panics if src.len() > N.

Source

pub const fn into_array(self) -> [u8; 20]

Returns the inner bytes array.

Source

pub fn covers(&self, b: &Self) -> bool

Returns true if all bits set in b are also set in self.

Source

pub const fn const_eq(&self, other: &Self) -> bool

Compile-time equality. NOT constant-time equality.

Source

pub const fn bit_and(self, rhs: Self) -> Self

Computes the bitwise AND of two FixedBytes.

Source

pub const fn bit_or(self, rhs: Self) -> Self

Computes the bitwise OR of two FixedBytes.

Source

pub const fn bit_xor(self, rhs: Self) -> Self

Computes the bitwise XOR of two FixedBytes.

Source§

impl Address

Source

pub fn from_word(word: FixedBytes<32>) -> Self

Creates an Ethereum address from an EVM word’s upper 20 bytes (word[12..]).

§Examples
let word = b256!("000000000000000000000000d8da6bf26964af9d7eed9e03e53415d37aa96045");
assert_eq!(Address::from_word(word), address!("d8da6bf26964af9d7eed9e03e53415d37aa96045"));
Source

pub fn into_word(&self) -> FixedBytes<32>

Left-pads the address to 32 bytes (EVM word size).

§Examples
assert_eq!(
    address!("d8da6bf26964af9d7eed9e03e53415d37aa96045").into_word(),
    b256!("000000000000000000000000d8da6bf26964af9d7eed9e03e53415d37aa96045"),
);
Source

pub fn parse_checksummed<S: AsRef<str>>( s: S, chain_id: Option<u64>, ) -> Result<Self, AddressError>

Parse an Ethereum address, verifying its EIP-55 checksum.

You can optionally specify an EIP-155 chain ID to check the address using EIP-1191.

§Errors

This method returns an error if the provided string does not match the expected checksum.

§Examples
let checksummed = "0xd8dA6BF26964aF9D7eEd9e03E53415D37aA96045";
let address = Address::parse_checksummed(checksummed, None).unwrap();
let expected = address!("d8da6bf26964af9d7eed9e03e53415d37aa96045");
assert_eq!(address, expected);
Source

pub fn to_checksum(&self, chain_id: Option<u64>) -> String

Encodes an Ethereum address to its EIP-55 checksum into a heap-allocated string.

You can optionally specify an EIP-155 chain ID to encode the address using EIP-1191.

§Examples
let address = address!("d8da6bf26964af9d7eed9e03e53415d37aa96045");

let checksummed: String = address.to_checksum(None);
assert_eq!(checksummed, "0xd8dA6BF26964aF9D7eEd9e03E53415D37aA96045");

let checksummed: String = address.to_checksum(Some(1));
assert_eq!(checksummed, "0xD8Da6bf26964Af9d7EEd9e03e53415d37AA96045");
Source

pub fn to_checksum_raw<'a>( &self, buf: &'a mut [u8], chain_id: Option<u64>, ) -> &'a mut str

Encodes an Ethereum address to its EIP-55 checksum into the given buffer.

For convenience, the buffer is returned as a &mut str, as the bytes are guaranteed to be valid UTF-8.

You can optionally specify an EIP-155 chain ID to encode the address using EIP-1191.

§Panics

Panics if buf is not exactly 42 bytes long.

§Examples
let address = address!("d8da6bf26964af9d7eed9e03e53415d37aa96045");
let mut buf = [0; 42];

let checksummed: &mut str = address.to_checksum_raw(&mut buf, None);
assert_eq!(checksummed, "0xd8dA6BF26964aF9D7eEd9e03E53415D37aA96045");

let checksummed: &mut str = address.to_checksum_raw(&mut buf, Some(1));
assert_eq!(checksummed, "0xD8Da6bf26964Af9d7EEd9e03e53415d37AA96045");
Source

pub fn to_checksum_buffer(&self, chain_id: Option<u64>) -> AddressChecksumBuffer

Encodes an Ethereum address to its EIP-55 checksum into a stack-allocated buffer.

You can optionally specify an EIP-155 chain ID to encode the address using EIP-1191.

§Examples
let address = address!("d8da6bf26964af9d7eed9e03e53415d37aa96045");

let mut buffer: AddressChecksumBuffer = address.to_checksum_buffer(None);
assert_eq!(buffer.as_str(), "0xd8dA6BF26964aF9D7eEd9e03E53415D37aA96045");

let checksummed: &str = buffer.format(&address, Some(1));
assert_eq!(checksummed, "0xD8Da6bf26964Af9d7EEd9e03e53415d37AA96045");
Source

pub fn create(&self, nonce: u64) -> Self

Available on crate feature rlp only.

Computes the create address for this address and nonce:

keccak256(rlp([sender, nonce]))[12:]

§Examples
let sender = address!("b20a608c624Ca5003905aA834De7156C68b2E1d0");

let expected = address!("00000000219ab540356cBB839Cbe05303d7705Fa");
assert_eq!(sender.create(0), expected);

let expected = address!("e33c6e89e69d085897f98e92b06ebd541d1daa99");
assert_eq!(sender.create(1), expected);
Source

pub fn create2_from_code<S, C>(&self, salt: S, init_code: C) -> Self
where S: Borrow<[u8; 32]>, C: AsRef<[u8]>,

Computes the CREATE2 address of a smart contract as specified in EIP-1014:

keccak256(0xff ++ address ++ salt ++ keccak256(init_code))[12:]

The init_code is the code that, when executed, produces the runtime bytecode that will be placed into the state, and which typically is used by high level languages to implement a ‘constructor’.

§Examples
let address = address!("8ba1f109551bD432803012645Ac136ddd64DBA72");
let salt = b256!("7c5ea36004851c764c44143b1dcb59679b11c9a68e5f41497f6cf3d480715331");
let init_code = bytes!("6394198df16000526103ff60206004601c335afa6040516060f3");
let expected = address!("533ae9d683B10C02EbDb05471642F85230071FC3");
assert_eq!(address.create2_from_code(salt, init_code), expected);
Source

pub fn create2<S, H>(&self, salt: S, init_code_hash: H) -> Self
where S: Borrow<[u8; 32]>, H: Borrow<[u8; 32]>,

Computes the CREATE2 address of a smart contract as specified in EIP-1014, taking the pre-computed hash of the init code as input:

keccak256(0xff ++ address ++ salt ++ init_code_hash)[12:]

The init_code is the code that, when executed, produces the runtime bytecode that will be placed into the state, and which typically is used by high level languages to implement a ‘constructor’.

§Examples
let address = address!("5C69bEe701ef814a2B6a3EDD4B1652CB9cc5aA6f");
let salt = b256!("2b2f5776e38002e0c013d0d89828fdb06fee595ea2d5ed4b194e3883e823e350");
let init_code_hash = b256!("96e8ac4277198ff8b6f785478aa9a39f403cb768dd02cbee326c3e7da348845f");
let expected = address!("0d4a11d5EEaaC28EC3F61d100daF4d40471f1852");
assert_eq!(address.create2(salt, init_code_hash), expected);
Source

pub fn from_raw_public_key(pubkey: &[u8]) -> Self

Instantiate by hashing public key bytes.

§Panics

If the input is not exactly 64 bytes

Source

pub fn from_public_key(pubkey: &VerifyingKey) -> Self

Available on crate feature k256 only.

Converts an ECDSA verifying key to its corresponding Ethereum address.

Source

pub fn from_private_key(private_key: &SigningKey) -> Self

Available on crate feature k256 only.

Converts an ECDSA signing key to its corresponding Ethereum address.

Methods from Deref<Target = FixedBytes<20>>§

Source

pub const ZERO: Self = _

Source

pub fn randomize(&mut self)

Available on crate feature getrandom only.

Fills this FixedBytes with cryptographically random content.

§Panics

Panics if the underlying call to getrandom_uninit fails.

Source

pub fn try_randomize(&mut self) -> Result<(), Error>

Available on crate feature getrandom only.

Tries to fill this FixedBytes with cryptographically random content.

§Errors

This function only propagates the error from the underlying call to getrandom_uninit.

Source

pub fn randomize_with<R: Rng + ?Sized>(&mut self, rng: &mut R)

Available on crate feature rand only.

Fills this FixedBytes with the given random number generator.

Source

pub fn as_slice(&self) -> &[u8]

Returns a slice containing the entire array. Equivalent to &s[..].

Source

pub fn as_mut_slice(&mut self) -> &mut [u8]

Returns a mutable slice containing the entire array. Equivalent to &mut s[..].

Source

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

Returns true if all bits set in self are also set in b.

Source

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

Compile-time equality. NOT constant-time equality.

Source

pub fn is_zero(&self) -> bool

Returns true if no bits are set.

Source

pub fn const_is_zero(&self) -> bool

Returns true if no bits are set.

Methods from Deref<Target = [u8; N]>§

Source

pub fn as_ascii(&self) -> Option<&[AsciiChar; N]>

🔬This is a nightly-only experimental API. (ascii_char)

Converts this array of bytes into an array of ASCII characters, or returns None if any of the characters is non-ASCII.

§Examples
#![feature(ascii_char)]

const HEX_DIGITS: [std::ascii::Char; 16] =
    *b"0123456789abcdef".as_ascii().unwrap();

assert_eq!(HEX_DIGITS[1].as_str(), "1");
assert_eq!(HEX_DIGITS[10].as_str(), "a");
Source

pub unsafe fn as_ascii_unchecked(&self) -> &[AsciiChar; N]

🔬This is a nightly-only experimental API. (ascii_char)

Converts this array of bytes into an array of ASCII characters, without checking whether they’re valid.

§Safety

Every byte in the array must be in 0..=127, or else this is UB.

1.57.0 · Source

pub fn as_slice(&self) -> &[T]

Returns a slice containing the entire array. Equivalent to &s[..].

1.57.0 · Source

pub fn as_mut_slice(&mut self) -> &mut [T]

Returns a mutable slice containing the entire array. Equivalent to &mut s[..].

1.77.0 · Source

pub fn each_ref(&self) -> [&T; N]

Borrows each element and returns an array of references with the same size as self.

§Example
let floats = [3.1, 2.7, -1.0];
let float_refs: [&f64; 3] = floats.each_ref();
assert_eq!(float_refs, [&3.1, &2.7, &-1.0]);

This method is particularly useful if combined with other methods, like map. This way, you can avoid moving the original array if its elements are not Copy.

let strings = ["Ferris".to_string(), "♥".to_string(), "Rust".to_string()];
let is_ascii = strings.each_ref().map(|s| s.is_ascii());
assert_eq!(is_ascii, [true, false, true]);

// We can still access the original array: it has not been moved.
assert_eq!(strings.len(), 3);
1.77.0 · Source

pub fn each_mut(&mut self) -> [&mut T; N]

Borrows each element mutably and returns an array of mutable references with the same size as self.

§Example

let mut floats = [3.1, 2.7, -1.0];
let float_refs: [&mut f64; 3] = floats.each_mut();
*float_refs[0] = 0.0;
assert_eq!(float_refs, [&mut 0.0, &mut 2.7, &mut -1.0]);
assert_eq!(floats, [0.0, 2.7, -1.0]);
Source

pub fn split_array_ref<const M: usize>(&self) -> (&[T; M], &[T])

🔬This is a nightly-only experimental API. (split_array)

Divides one array reference into two at an index.

The first will contain all indices from [0, M) (excluding the index M itself) and the second will contain all indices from [M, N) (excluding the index N itself).

§Panics

Panics if M > N.

§Examples
#![feature(split_array)]

let v = [1, 2, 3, 4, 5, 6];

{
   let (left, right) = v.split_array_ref::<0>();
   assert_eq!(left, &[]);
   assert_eq!(right, &[1, 2, 3, 4, 5, 6]);
}

{
    let (left, right) = v.split_array_ref::<2>();
    assert_eq!(left, &[1, 2]);
    assert_eq!(right, &[3, 4, 5, 6]);
}

{
    let (left, right) = v.split_array_ref::<6>();
    assert_eq!(left, &[1, 2, 3, 4, 5, 6]);
    assert_eq!(right, &[]);
}
Source

pub fn split_array_mut<const M: usize>(&mut self) -> (&mut [T; M], &mut [T])

🔬This is a nightly-only experimental API. (split_array)

Divides one mutable array reference into two at an index.

The first will contain all indices from [0, M) (excluding the index M itself) and the second will contain all indices from [M, N) (excluding the index N itself).

§Panics

Panics if M > N.

§Examples
#![feature(split_array)]

let mut v = [1, 0, 3, 0, 5, 6];
let (left, right) = v.split_array_mut::<2>();
assert_eq!(left, &mut [1, 0][..]);
assert_eq!(right, &mut [3, 0, 5, 6]);
left[1] = 2;
right[1] = 4;
assert_eq!(v, [1, 2, 3, 4, 5, 6]);
Source

pub fn rsplit_array_ref<const M: usize>(&self) -> (&[T], &[T; M])

🔬This is a nightly-only experimental API. (split_array)

Divides one array reference into two at an index from the end.

The first will contain all indices from [0, N - M) (excluding the index N - M itself) and the second will contain all indices from [N - M, N) (excluding the index N itself).

§Panics

Panics if M > N.

§Examples
#![feature(split_array)]

let v = [1, 2, 3, 4, 5, 6];

{
   let (left, right) = v.rsplit_array_ref::<0>();
   assert_eq!(left, &[1, 2, 3, 4, 5, 6]);
   assert_eq!(right, &[]);
}

{
    let (left, right) = v.rsplit_array_ref::<2>();
    assert_eq!(left, &[1, 2, 3, 4]);
    assert_eq!(right, &[5, 6]);
}

{
    let (left, right) = v.rsplit_array_ref::<6>();
    assert_eq!(left, &[]);
    assert_eq!(right, &[1, 2, 3, 4, 5, 6]);
}
Source

pub fn rsplit_array_mut<const M: usize>(&mut self) -> (&mut [T], &mut [T; M])

🔬This is a nightly-only experimental API. (split_array)

Divides one mutable array reference into two at an index from the end.

The first will contain all indices from [0, N - M) (excluding the index N - M itself) and the second will contain all indices from [N - M, N) (excluding the index N itself).

§Panics

Panics if M > N.

§Examples
#![feature(split_array)]

let mut v = [1, 0, 3, 0, 5, 6];
let (left, right) = v.rsplit_array_mut::<4>();
assert_eq!(left, &mut [1, 0]);
assert_eq!(right, &mut [3, 0, 5, 6][..]);
left[1] = 2;
right[1] = 4;
assert_eq!(v, [1, 2, 3, 4, 5, 6]);

Trait Implementations§

Source§

impl Allocative for Address

Available on crate feature allocative only.
Source§

fn visit<'a, 'b: 'a>(&self, visitor: &'a mut Visitor<'b>)

Source§

impl<'a> Arbitrary<'a> for Address

Available on crate feature arbitrary only.
Source§

fn arbitrary(u: &mut Unstructured<'a>) -> Result<Self>

Generate an arbitrary value of Self from the given unstructured data. Read more
Source§

fn arbitrary_take_rest(u: Unstructured<'a>) -> Result<Self>

Generate an arbitrary value of Self from the entirety of the given unstructured data. Read more
Source§

fn size_hint(depth: usize) -> (usize, Option<usize>)

Get a size hint for how many bytes out of an Unstructured this type needs to construct itself. Read more
Source§

fn try_size_hint( depth: usize, ) -> Result<(usize, Option<usize>), MaxRecursionReached>

Get a size hint for how many bytes out of an Unstructured this type needs to construct itself. Read more
Source§

impl Arbitrary for Address

Available on crate feature arbitrary only.
Source§

type Parameters = <FixedBytes<20> as Arbitrary>::Parameters

The type of parameters that arbitrary_with accepts for configuration of the generated Strategy. Parameters must implement Default.
Source§

type Strategy = Map<<FixedBytes<20> as Arbitrary>::Strategy, fn(_: FixedBytes<20>) -> Address>

The type of Strategy used to generate values of type Self.
Source§

fn arbitrary() -> Self::Strategy

Generates a Strategy for producing arbitrary values of type the implementing type (Self). Read more
Source§

fn arbitrary_with(args: Self::Parameters) -> Self::Strategy

Generates a Strategy for producing arbitrary values of type the implementing type (Self). The strategy is passed the arguments given in args. Read more
Source§

impl AsMut<[u8]> for Address

Source§

fn as_mut(&mut self) -> &mut [u8]

Converts this type into a mutable reference of the (usually inferred) input type.
Source§

impl AsMut<[u8; 20]> for Address

Source§

fn as_mut(&mut self) -> &mut [u8; 20]

Converts this type into a mutable reference of the (usually inferred) input type.
Source§

impl AsMut<FixedBytes<20>> for Address

Source§

fn as_mut(&mut self) -> &mut FixedBytes<20>

Converts this type into a mutable reference of the (usually inferred) input type.
Source§

impl AsRef<[u8]> for Address

Source§

fn as_ref(&self) -> &[u8]

Converts this type into a shared reference of the (usually inferred) input type.
Source§

impl AsRef<[u8; 20]> for Address

Source§

fn as_ref(&self) -> &[u8; 20]

Converts this type into a shared reference of the (usually inferred) input type.
Source§

impl AsRef<FixedBytes<20>> for Address

Source§

fn as_ref(&self) -> &FixedBytes<20>

Converts this type into a shared reference of the (usually inferred) input type.
Source§

impl BitAnd for Address

Source§

type Output = Address

The resulting type after applying the & operator.
Source§

fn bitand(self, rhs: Address) -> Address

Performs the & operation. Read more
Source§

impl BitAndAssign for Address

Source§

fn bitand_assign(&mut self, rhs: Address)

Performs the &= operation. Read more
Source§

impl BitOr for Address

Source§

type Output = Address

The resulting type after applying the | operator.
Source§

fn bitor(self, rhs: Address) -> Address

Performs the | operation. Read more
Source§

impl BitOrAssign for Address

Source§

fn bitor_assign(&mut self, rhs: Address)

Performs the |= operation. Read more
Source§

impl BitXor for Address

Source§

type Output = Address

The resulting type after applying the ^ operator.
Source§

fn bitxor(self, rhs: Address) -> Address

Performs the ^ operation. Read more
Source§

impl BitXorAssign for Address

Source§

fn bitxor_assign(&mut self, rhs: Address)

Performs the ^= operation. Read more
Source§

impl Borrow<[u8]> for &Address

Source§

fn borrow(&self) -> &[u8]

Immutably borrows from an owned value. Read more
Source§

impl Borrow<[u8]> for &mut Address

Source§

fn borrow(&self) -> &[u8]

Immutably borrows from an owned value. Read more
Source§

impl Borrow<[u8]> for Address

Source§

fn borrow(&self) -> &[u8]

Immutably borrows from an owned value. Read more
Source§

impl Borrow<[u8; 20]> for &Address

Source§

fn borrow(&self) -> &[u8; 20]

Immutably borrows from an owned value. Read more
Source§

impl Borrow<[u8; 20]> for &mut Address

Source§

fn borrow(&self) -> &[u8; 20]

Immutably borrows from an owned value. Read more
Source§

impl Borrow<[u8; 20]> for Address

Source§

fn borrow(&self) -> &[u8; 20]

Immutably borrows from an owned value. Read more
Source§

impl BorrowMut<[u8]> for &mut Address

Source§

fn borrow_mut(&mut self) -> &mut [u8]

Mutably borrows from an owned value. Read more
Source§

impl BorrowMut<[u8]> for Address

Source§

fn borrow_mut(&mut self) -> &mut [u8]

Mutably borrows from an owned value. Read more
Source§

impl BorrowMut<[u8; 20]> for &mut Address

Source§

fn borrow_mut(&mut self) -> &mut [u8; 20]

Mutably borrows from an owned value. Read more
Source§

impl BorrowMut<[u8; 20]> for Address

Source§

fn borrow_mut(&mut self) -> &mut [u8; 20]

Mutably borrows from an owned value. Read more
Source§

impl Clone for Address

Source§

fn clone(&self) -> Address

Returns a copy of the value. Read more
1.0.0 · 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 Decodable for Address

Available on crate feature rlp only.
Source§

fn decode(buf: &mut &[u8]) -> Result<Self>

Decodes the blob into the appropriate type. buf must be advanced past the decoded object.
Source§

impl Default for Address

Source§

fn default() -> Address

Returns the “default value” for a type. Read more
Source§

impl Deref for Address

Source§

type Target = FixedBytes<20>

The resulting type after dereferencing.
Source§

fn deref(&self) -> &Self::Target

Dereferences the value.
Source§

impl DerefMut for Address

Source§

fn deref_mut(&mut self) -> &mut Self::Target

Mutably dereferences the value.
Source§

impl<'de> Deserialize<'de> for Address

Available on crate feature serde only.
Source§

fn deserialize<D: Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error>

Deserialize this value from the given Serde deserializer. Read more
Source§

impl Display for Address

Source§

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

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

impl Distribution<Address> for Standard

Available on crate feature rand only.
Source§

fn sample<R: Rng + ?Sized>(&self, rng: &mut R) -> Address

Generate a random value of T, using rng as the source of randomness.
Source§

fn sample_iter<R>(self, rng: R) -> DistIter<Self, R, T>
where R: Rng, Self: Sized,

Create an iterator that generates random values of T, using rng as the source of randomness. Read more
Source§

fn map<F, S>(self, func: F) -> DistMap<Self, F, T, S>
where F: Fn(T) -> S, Self: Sized,

Create a distribution of values of ‘S’ by mapping the output of Self through the closure F Read more
Source§

impl Encodable for Address

Available on crate feature rlp only.
Source§

fn length(&self) -> usize

Returns the length of the encoding of this type in bytes. Read more
Source§

fn encode(&self, out: &mut dyn BufMut)

Encodes the type into the out buffer.
Source§

impl<'a> From<&'a [u8; 20]> for &'a Address

Source§

fn from(value: &'a [u8; 20]) -> &'a Address

Converts to this type from the input type.
Source§

impl<'a> From<&'a [u8; 20]> for Address

Source§

fn from(value: &'a [u8; 20]) -> Self

Converts to this type from the input type.
Source§

impl<'a> From<&'a Address> for &'a [u8; 20]

Source§

fn from(value: &'a Address) -> &'a [u8; 20]

Converts to this type from the input type.
Source§

impl<'a> From<&'a mut [u8; 20]> for &'a Address

Source§

fn from(value: &'a mut [u8; 20]) -> &'a Address

Converts to this type from the input type.
Source§

impl<'a> From<&'a mut [u8; 20]> for &'a mut Address

Source§

fn from(value: &'a mut [u8; 20]) -> &'a mut Address

Converts to this type from the input type.
Source§

impl<'a> From<&'a mut [u8; 20]> for Address

Source§

fn from(value: &'a mut [u8; 20]) -> Self

Converts to this type from the input type.
Source§

impl<'a> From<&'a mut Address> for &'a [u8; 20]

Source§

fn from(value: &'a mut Address) -> &'a [u8; 20]

Converts to this type from the input type.
Source§

impl<'a> From<&'a mut Address> for &'a mut [u8; 20]

Source§

fn from(value: &'a mut Address) -> &'a mut [u8; 20]

Converts to this type from the input type.
Source§

impl From<[u8; 20]> for Address

Source§

fn from(value: [u8; 20]) -> Self

Converts to this type from the input type.
Source§

impl From<Address> for [u8; 20]

Source§

fn from(value: Address) -> Self

Converts to this type from the input type.
Source§

impl From<Address> for FixedBytes<20>

Source§

fn from(value: Address) -> Self

Converts to this type from the input type.
Source§

impl From<Address> for TxKind

Source§

fn from(value: Address) -> Self

Creates a TxKind::Call with the given address.

Source§

impl From<Address> for U160

Source§

fn from(value: Address) -> Self

Converts to this type from the input type.
Source§

impl From<FixedBytes<20>> for Address

Source§

fn from(value: FixedBytes<20>) -> Self

Converts to this type from the input type.
Source§

impl From<Uint<160, 3>> for Address

Source§

fn from(value: U160) -> Self

Converts to this type from the input type.
Source§

impl FromHex for Address

Source§

type Error = FromHexError

Source§

fn from_hex<T: AsRef<[u8]>>(hex: T) -> Result<Self, Self::Error>

Creates an instance of type Self from the given hex string, or fails with a custom error type. Read more
Source§

impl FromStr for Address

Source§

type Err = <FixedBytes<20> as FromStr>::Err

The associated error which can be returned from parsing.
Source§

fn from_str(src: &str) -> Result<Self, Self::Err>

Parses a string s to return a value of this type. Read more
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<__IdxT> Index<__IdxT> for Address
where FixedBytes<20>: Index<__IdxT>,

Source§

type Output = <FixedBytes<20> as Index<__IdxT>>::Output

The returned type after indexing.
Source§

fn index(&self, idx: __IdxT) -> &Self::Output

Performs the indexing (container[index]) operation. Read more
Source§

impl<__IdxT> IndexMut<__IdxT> for Address
where FixedBytes<20>: IndexMut<__IdxT>,

Source§

fn index_mut(&mut self, idx: __IdxT) -> &mut Self::Output

Performs the mutable indexing (container[index]) operation. Read more
Source§

impl<'__deriveMoreLifetime> IntoIterator for &'__deriveMoreLifetime Address
where &'__deriveMoreLifetime FixedBytes<20>: IntoIterator,

Source§

type Item = <&'__deriveMoreLifetime FixedBytes<20> as IntoIterator>::Item

The type of the elements being iterated over.
Source§

type IntoIter = <&'__deriveMoreLifetime FixedBytes<20> as IntoIterator>::IntoIter

Which kind of iterator are we turning this into?
Source§

fn into_iter(self) -> Self::IntoIter

Creates an iterator from a value. Read more
Source§

impl<'__deriveMoreLifetime> IntoIterator for &'__deriveMoreLifetime mut Address
where &'__deriveMoreLifetime mut FixedBytes<20>: IntoIterator,

Source§

type Item = <&'__deriveMoreLifetime mut FixedBytes<20> as IntoIterator>::Item

The type of the elements being iterated over.
Source§

type IntoIter = <&'__deriveMoreLifetime mut FixedBytes<20> as IntoIterator>::IntoIter

Which kind of iterator are we turning this into?
Source§

fn into_iter(self) -> Self::IntoIter

Creates an iterator from a value. Read more
Source§

impl IntoIterator for Address

Source§

type Item = <FixedBytes<20> as IntoIterator>::Item

The type of the elements being iterated over.
Source§

type IntoIter = <FixedBytes<20> as IntoIterator>::IntoIter

Which kind of iterator are we turning this into?
Source§

fn into_iter(self) -> Self::IntoIter

Creates an iterator from a value. Read more
Source§

impl LowerHex for Address

Source§

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

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

impl MaxEncodedLenAssoc for Address

Source§

const LEN: usize = 21usize

The maximum length.
Source§

impl Not for Address

Source§

type Output = Address

The resulting type after applying the ! operator.
Source§

fn not(self) -> Address

Performs the unary ! operation. Read more
Source§

impl Ord for Address

Source§

fn cmp(&self, other: &Address) -> Ordering

This method returns an Ordering between self and other. Read more
1.21.0 · Source§

fn max(self, other: Self) -> Self
where Self: Sized,

Compares and returns the maximum of two values. Read more
1.21.0 · Source§

fn min(self, other: Self) -> Self
where Self: Sized,

Compares and returns the minimum of two values. Read more
1.50.0 · Source§

fn clamp(self, min: Self, max: Self) -> Self
where Self: Sized,

Restrict a value to a certain interval. Read more
Source§

impl PartialEq<&[u8]> for Address

Source§

fn eq(&self, other: &&[u8]) -> bool

Tests for self and other values to be equal, and is used by ==.
1.0.0 · Source§

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

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
Source§

impl PartialEq<&[u8; 20]> for Address

Source§

fn eq(&self, other: &&[u8; 20]) -> bool

Tests for self and other values to be equal, and is used by ==.
1.0.0 · Source§

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

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
Source§

impl PartialEq<&Address> for [u8]

Source§

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

Tests for self and other values to be equal, and is used by ==.
1.0.0 · Source§

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

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
Source§

impl PartialEq<&Address> for [u8; 20]

Source§

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

Tests for self and other values to be equal, and is used by ==.
1.0.0 · Source§

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

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
Source§

impl PartialEq<[u8]> for &Address

Source§

fn eq(&self, other: &[u8]) -> bool

Tests for self and other values to be equal, and is used by ==.
1.0.0 · Source§

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

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
Source§

impl PartialEq<[u8]> for Address

Source§

fn eq(&self, other: &[u8]) -> bool

Tests for self and other values to be equal, and is used by ==.
1.0.0 · Source§

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

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
Source§

impl PartialEq<[u8; 20]> for &Address

Source§

fn eq(&self, other: &[u8; 20]) -> bool

Tests for self and other values to be equal, and is used by ==.
1.0.0 · Source§

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

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
Source§

impl PartialEq<[u8; 20]> for Address

Source§

fn eq(&self, other: &[u8; 20]) -> bool

Tests for self and other values to be equal, and is used by ==.
1.0.0 · Source§

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

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
Source§

impl PartialEq<Address> for &[u8]

Source§

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

Tests for self and other values to be equal, and is used by ==.
1.0.0 · Source§

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

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
Source§

impl PartialEq<Address> for &[u8; 20]

Source§

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

Tests for self and other values to be equal, and is used by ==.
1.0.0 · Source§

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

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
Source§

impl PartialEq<Address> for [u8]

Source§

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

Tests for self and other values to be equal, and is used by ==.
1.0.0 · Source§

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

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
Source§

impl PartialEq<Address> for [u8; 20]

Source§

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

Tests for self and other values to be equal, and is used by ==.
1.0.0 · Source§

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

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
Source§

impl PartialEq for Address

Source§

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

Tests for self and other values to be equal, and is used by ==.
1.0.0 · Source§

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

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
Source§

impl PartialOrd<&[u8]> for Address

Source§

fn partial_cmp(&self, other: &&[u8]) -> Option<Ordering>

This method returns an ordering between self and other values if one exists. Read more
1.0.0 · Source§

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

Tests less than (for self and other) and is used by the < operator. Read more
1.0.0 · Source§

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

Tests less than or equal to (for self and other) and is used by the <= operator. Read more
1.0.0 · Source§

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

Tests greater than (for self and other) and is used by the > operator. Read more
1.0.0 · Source§

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

Tests greater than or equal to (for self and other) and is used by the >= operator. Read more
Source§

impl PartialOrd<&Address> for [u8]

Source§

fn partial_cmp(&self, other: &&Address) -> Option<Ordering>

This method returns an ordering between self and other values if one exists. Read more
1.0.0 · Source§

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

Tests less than (for self and other) and is used by the < operator. Read more
1.0.0 · Source§

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

Tests less than or equal to (for self and other) and is used by the <= operator. Read more
1.0.0 · Source§

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

Tests greater than (for self and other) and is used by the > operator. Read more
1.0.0 · Source§

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

Tests greater than or equal to (for self and other) and is used by the >= operator. Read more
Source§

impl PartialOrd<[u8]> for &Address

Source§

fn partial_cmp(&self, other: &[u8]) -> Option<Ordering>

This method returns an ordering between self and other values if one exists. Read more
1.0.0 · Source§

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

Tests less than (for self and other) and is used by the < operator. Read more
1.0.0 · Source§

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

Tests less than or equal to (for self and other) and is used by the <= operator. Read more
1.0.0 · Source§

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

Tests greater than (for self and other) and is used by the > operator. Read more
1.0.0 · Source§

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

Tests greater than or equal to (for self and other) and is used by the >= operator. Read more
Source§

impl PartialOrd<[u8]> for Address

Source§

fn partial_cmp(&self, other: &[u8]) -> Option<Ordering>

This method returns an ordering between self and other values if one exists. Read more
1.0.0 · Source§

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

Tests less than (for self and other) and is used by the < operator. Read more
1.0.0 · Source§

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

Tests less than or equal to (for self and other) and is used by the <= operator. Read more
1.0.0 · Source§

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

Tests greater than (for self and other) and is used by the > operator. Read more
1.0.0 · Source§

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

Tests greater than or equal to (for self and other) and is used by the >= operator. Read more
Source§

impl PartialOrd<Address> for &[u8]

Source§

fn partial_cmp(&self, other: &Address) -> Option<Ordering>

This method returns an ordering between self and other values if one exists. Read more
1.0.0 · Source§

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

Tests less than (for self and other) and is used by the < operator. Read more
1.0.0 · Source§

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

Tests less than or equal to (for self and other) and is used by the <= operator. Read more
1.0.0 · Source§

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

Tests greater than (for self and other) and is used by the > operator. Read more
1.0.0 · Source§

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

Tests greater than or equal to (for self and other) and is used by the >= operator. Read more
Source§

impl PartialOrd<Address> for [u8]

Source§

fn partial_cmp(&self, other: &Address) -> Option<Ordering>

This method returns an ordering between self and other values if one exists. Read more
1.0.0 · Source§

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

Tests less than (for self and other) and is used by the < operator. Read more
1.0.0 · Source§

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

Tests less than or equal to (for self and other) and is used by the <= operator. Read more
1.0.0 · Source§

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

Tests greater than (for self and other) and is used by the > operator. Read more
1.0.0 · Source§

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

Tests greater than or equal to (for self and other) and is used by the >= operator. Read more
Source§

impl PartialOrd for Address

Source§

fn partial_cmp(&self, other: &Address) -> Option<Ordering>

This method returns an ordering between self and other values if one exists. Read more
1.0.0 · Source§

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

Tests less than (for self and other) and is used by the < operator. Read more
1.0.0 · Source§

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

Tests less than or equal to (for self and other) and is used by the <= operator. Read more
1.0.0 · Source§

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

Tests greater than (for self and other) and is used by the > operator. Read more
1.0.0 · Source§

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

Tests greater than or equal to (for self and other) and is used by the >= operator. Read more
Source§

impl Serialize for Address

Available on crate feature serde only.
Source§

fn serialize<S: Serializer>(&self, serializer: S) -> Result<S::Ok, S::Error>

Serialize this value into the given Serde serializer. Read more
Source§

impl<'a> TryFrom<&'a [u8]> for &'a Address

Source§

type Error = TryFromSliceError

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

fn try_from(slice: &'a [u8]) -> Result<&'a Address, Self::Error>

Performs the conversion.
Source§

impl TryFrom<&[u8]> for Address

Source§

type Error = TryFromSliceError

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

fn try_from(slice: &[u8]) -> Result<Self, Self::Error>

Performs the conversion.
Source§

impl<'a> TryFrom<&'a mut [u8]> for &'a mut Address

Source§

type Error = TryFromSliceError

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

fn try_from(slice: &'a mut [u8]) -> Result<&'a mut Address, Self::Error>

Performs the conversion.
Source§

impl TryFrom<&mut [u8]> for Address

Source§

type Error = TryFromSliceError

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

fn try_from(slice: &mut [u8]) -> Result<Self, Self::Error>

Performs the conversion.
Source§

impl UpperHex for Address

Source§

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

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

impl Copy for Address

Source§

impl Eq for Address

Source§

impl MaxEncodedLen<{ $len }> for Address

Source§

impl StructuralPartialEq for Address

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, dst: *mut T)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dst. Read more
Source§

impl<Q, K> Comparable<K> for Q
where Q: Ord + ?Sized, K: Borrow<Q> + ?Sized,

Source§

fn compare(&self, key: &K) -> Ordering

Compare self to key and return their ordering.
Source§

impl<Q, K> Equivalent<K> for Q
where Q: Eq + ?Sized, K: Borrow<Q> + ?Sized,

Source§

fn equivalent(&self, key: &K) -> bool

Checks if this value is equivalent to the given key. Read more
Source§

impl<Q, K> Equivalent<K> for Q
where Q: Eq + ?Sized, K: Borrow<Q> + ?Sized,

Source§

fn equivalent(&self, key: &K) -> bool

Compare self to key and return true if they are equal.
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> ToHex for T
where T: AsRef<[u8]>,

Source§

fn encode_hex<U>(&self) -> U
where U: FromIterator<char>,

👎Deprecated: use ToHexExt instead
Encode the hex strict representing self into the result. Lower case letters are used (e.g. f9b4ca).
Source§

fn encode_hex_upper<U>(&self) -> U
where U: FromIterator<char>,

👎Deprecated: use ToHexExt instead
Encode the hex strict representing self into the result. Upper case letters are used (e.g. F9B4CA).
Source§

impl<T> ToHex for T
where T: AsRef<[u8]>,

Source§

fn encode_hex<U>(&self) -> U
where U: FromIterator<char>,

Encode the hex strict representing self into the result. Lower case letters are used (e.g. f9b4ca)
Source§

fn encode_hex_upper<U>(&self) -> U
where U: FromIterator<char>,

Encode the hex strict representing self into the result. Upper case letters are used (e.g. F9B4CA)
Source§

impl<T> ToHexExt for T
where T: AsRef<[u8]>,

Source§

fn encode_hex(&self) -> String

Encode the hex strict representing self into the result. Lower case letters are used (e.g. f9b4ca).
Source§

fn encode_hex_upper(&self) -> String

Encode the hex strict representing self into the result. Upper case letters are used (e.g. F9B4CA).
Source§

fn encode_hex_with_prefix(&self) -> String

Encode the hex strict representing self into the result with prefix 0x. Lower case letters are used (e.g. 0xf9b4ca).
Source§

fn encode_hex_upper_with_prefix(&self) -> String

Encode the hex strict representing self into the result with prefix 0X. Upper case letters are used (e.g. 0xF9B4CA).
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> ToString for T
where T: Display + ?Sized,

Source§

default fn to_string(&self) -> String

Converts the given value to a String. Read more
Source§

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

Source§

type Error = Infallible

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

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

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.
Source§

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

Source§

fn vzip(self) -> V

Source§

impl<T> DeserializeOwned for T
where T: for<'de> Deserialize<'de>,