Struct clarity::address::Address

source ·
pub struct Address(/* private fields */);
Expand description

Representation of an Ethereum address.

Address is usually derived from a PrivateKey, or converted from its textual representation.

Implementations§

source§

impl Address

source

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

Get raw bytes of the address.

source

pub fn from_slice(data: &[u8]) -> Result<Address, Error>

Creates an Address from a slice.

This requires a slice to be exactly 20 bytes in length,

source

pub fn from_rlp_data(data: RlpToken) -> Result<Address, Error>

Attempts to decode an address from RLP data, with special case handling for the zero address case

source

pub fn parse_and_validate(input: &str) -> Result<Address, Error>

Trait Implementations§

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 Default for Address

source§

fn default() -> Address

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

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

source§

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

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 From<&Address> for AbiToken

source§

fn from(v: &Address) -> AbiToken

Converts to this type from the input type.
source§

impl From<&Address> for RlpToken

source§

fn from(value: &Address) -> Self

Converts to this type from the input type.
source§

impl From<[u8; 20]> for Address

source§

fn from(val: [u8; 20]) -> Address

Converts to this type from the input type.
source§

impl From<[u8; 32]> for Address

source§

fn from(val: [u8; 32]) -> Address

Converts to this type from the input type.
source§

impl From<Address> for AbiToken

source§

fn from(v: Address) -> AbiToken

Converts to this type from the input type.
source§

impl From<Address> for RlpToken

source§

fn from(value: Address) -> Self

Converts to this type from the input type.
source§

impl FromStr for Address

source§

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

Parses a string into a valid Ethereum address.

§Supported formats
  • 0x prefixed address
  • Raw bytes of an address represented by a bytes as an hexadecimal.
§Examples
use clarity::Address;
// Method 1
Address::from_str("0x0102030405060708090a0b0c0d0e0f1011121314").unwrap();
// Method 1 (without 0x prefix)
Address::from_str("0102030405060708090a0b0c0d0e0f1011121314").unwrap();
// Method 2
let _address : Address = "14131211100f0e0d0c0b0a090807060504030201".parse().unwrap();
§

type Err = Error

The associated error which can be returned from parsing.
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 Into<[u8; 20]> for Address

source§

fn into(self) -> [u8; 20]

Converts this type into the (usually inferred) input type.
source§

impl Into<[u8; 32]> for Address

source§

fn into(self) -> [u8; 32]

Converts this type into the (usually inferred) input type.
source§

impl LowerHex for Address

source§

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

Formats the value using the given formatter.
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 + PartialOrd,

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

impl PartialEq for Address

source§

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

This method tests for self and other values to be equal, and is used by ==.
1.0.0 · source§

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

This method tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
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

This method 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

This method 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

This method 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

This method tests greater than or equal to (for self and other) and is used by the >= operator. Read more
source§

impl Serialize for Address

source§

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

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

impl TryFrom<Uint256> for Address

§

type Error = Error

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

fn try_from(value: Uint256) -> Result<Self, Self::Error>

Performs the conversion.
source§

impl UpperHex for Address

source§

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

Formats the value using the given formatter.
source§

impl Copy for Address

source§

impl Eq 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<U> As for U

source§

fn as_<T>(self) -> T
where T: CastFrom<U>,

Casts self to type T. The semantics of numeric casting with the as operator are followed, so <T as As>::as_::<U> can be used in the same way as T as U for numeric conversions. 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> 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

§

type Output = T

Should always be Self
source§

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

§

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>,

§

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>,

§

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<T> DeserializeOwned for T
where T: for<'de> Deserialize<'de>,