Struct cosmwasm_std::Addr[][src]

pub struct Addr(_);

A human readable address.

In Cosmos, this is typically bech32 encoded. But for multi-chain smart contracts no assumptions should be made other than being UTF-8 encoded and of reasonable length.

This type represents a validated address. It can be created in the following ways

  1. Use Addr::unchecked(input)
  2. Use let checked: Addr = deps.api.addr_validate(input)?
  3. Use let checked: Addr = deps.api.addr_humanize(canonical_addr)?
  4. Deserialize from JSON. This must only be done from JSON that was validated before such as a contract’s state. Addr must not be used in messages sent by the user because this would result in unvalidated instances.

This type is immutable. If you really need to mutate it (Really? Are you sure?), create a mutable copy using let mut mutable = Addr::to_string() and operate on that String instance.

Implementations

impl Addr[src]

pub fn unchecked<T: Into<String>>(input: T) -> Addr[src]

Creates a new Addr instance from the given input without checking the validity of the input. Since Addr must always contain valid addresses, the caller is responsible for ensuring the input is valid.

Use this in cases where the address was validated before or in test code. If you see this in contract code, it should most likely be replaced with let checked: Addr = deps.api.addr_humanize(canonical_addr)?.

Examples

let address = Addr::unchecked("foobar");
assert_eq!(address, "foobar");

pub fn as_str(&self) -> &str[src]

Trait Implementations

impl AsRef<str> for Addr[src]

impl Clone for Addr[src]

impl Debug for Addr[src]

impl<'de> Deserialize<'de> for Addr[src]

impl Display for Addr[src]

impl Eq for Addr[src]

impl From<&'_ Addr> for HumanAddr[src]

impl From<Addr> for HumanAddr[src]

impl Hash for Addr[src]

impl JsonSchema for Addr[src]

impl Ord for Addr[src]

impl PartialEq<&'_ str> for Addr[src]

Implement Addr == &str

impl PartialEq<Addr> for Addr[src]

impl PartialEq<Addr> for &str[src]

Implement &str == Addr

impl PartialEq<String> for Addr[src]

Implement Addr == String

impl PartialOrd<Addr> for Addr[src]

impl Serialize for Addr[src]

impl StructuralEq for Addr[src]

impl StructuralPartialEq for Addr[src]

Auto Trait Implementations

impl RefUnwindSafe for Addr

impl Send for Addr

impl Sync for Addr

impl Unpin for Addr

impl UnwindSafe for Addr

Blanket Implementations

impl<T> Any for T where
    T: 'static + ?Sized
[src]

impl<T> Borrow<T> for T where
    T: ?Sized
[src]

impl<T> BorrowMut<T> for T where
    T: ?Sized
[src]

impl<T> Conv for T

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

impl<T> DynClone for T where
    T: Clone
[src]

impl<T> FmtForward for T

impl<T> From<T> for T[src]

impl<T, U> Into<U> for T where
    U: From<T>, 
[src]

impl<T> Pipe for T

impl<T> PipeAsRef for T

impl<T> PipeBorrow for T

impl<T> PipeDeref for T

impl<T> PipeRef for T

impl<T> Same<T> for T

type Output = T

Should always be Self

impl<T> Tap for T

impl<T, U> TapAsRef<U> for T where
    U: ?Sized

impl<T, U> TapBorrow<U> for T where
    U: ?Sized

impl<T> TapDeref for T

impl<T> ToOwned for T where
    T: Clone
[src]

type Owned = T

The resulting type after obtaining ownership.

impl<T> ToString for T where
    T: Display + ?Sized
[src]

impl<T> TryConv for T

impl<T, U> TryFrom<U> for T where
    U: Into<T>, 
[src]

type Error = Infallible

The type returned in the event of a conversion error.

impl<T, U> TryInto<U> for T where
    U: TryFrom<T>, 
[src]

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.