Struct levana_perpswap_cosmos::prelude::Addr

pub struct Addr(/* private fields */);
Expand description

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

pub fn unchecked(input: impl Into<String>) -> Addr

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.as_str(), "foobar");

pub fn as_str(&self) -> &str

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

Returns the UTF-8 encoded address string as a byte array.

This is equivalent to address.as_str().as_bytes().

pub fn into_string(self) -> String

Utility for explicit conversion to String.

Trait Implementations§

§

impl AsRef<str> for Addr

§

fn as_ref(&self) -> &str

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

impl<'a> Bounder<'a> for &'a Addr

§

fn inclusive_bound(self) -> Option<Bound<'a, &'a Addr>>

§

fn exclusive_bound(self) -> Option<Bound<'a, &'a Addr>>

§

impl<'a> Bounder<'a> for Addr

§

impl Clone for Addr

§

fn clone(&self) -> Addr

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
§

impl Debug for Addr

§

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

Formats the value using the given formatter. Read more
§

impl<'de> Deserialize<'de> for Addr

§

fn deserialize<__D>( __deserializer: __D, ) -> Result<Addr, <__D as Deserializer<'de>>::Error>
where __D: Deserializer<'de>,

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

impl Display for Addr

§

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

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

impl From<&Addr> for RawAddr

source§

fn from(addr: &Addr) -> Self

Converts to this type from the input type.
source§

impl From<Addr> for RawAddr

source§

fn from(addr: Addr) -> Self

Converts to this type from the input type.
§

impl Hash for Addr

§

fn hash<__H>(&self, state: &mut __H)
where __H: Hasher,

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
§

impl JsonSchema for Addr

§

fn schema_name() -> String

The name of the generated JSON Schema. Read more
§

fn schema_id() -> Cow<'static, str>

Returns a string that uniquely identifies the schema produced by this type. Read more
§

fn json_schema(gen: &mut SchemaGenerator) -> Schema

Generates a JSON Schema for this type. Read more
§

fn is_referenceable() -> bool

Whether JSON Schemas generated for this type should be re-used where possible using the $ref keyword. Read more
§

impl KeyDeserialize for &Addr

§

type Output = Addr

§

const KEY_ELEMS: u16 = 1u16

The number of key elements is used for the deserialization of compound keys. It should be equal to PrimaryKey::key().len()
§

fn from_vec( value: Vec<u8>, ) -> Result<<&Addr as KeyDeserialize>::Output, StdError>

§

fn from_slice(value: &[u8]) -> Result<Self::Output, StdError>

§

impl KeyDeserialize for Addr

§

type Output = Addr

§

const KEY_ELEMS: u16 = 1u16

The number of key elements is used for the deserialization of compound keys. It should be equal to PrimaryKey::key().len()
§

fn from_vec( value: Vec<u8>, ) -> Result<<Addr as KeyDeserialize>::Output, StdError>

§

fn from_slice(value: &[u8]) -> Result<Self::Output, StdError>

§

impl Ord for Addr

§

fn cmp(&self, other: &Addr) -> 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
§

impl PartialEq<&Addr> for Addr

§

fn eq(&self, rhs: &&Addr) -> 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.
§

impl<'a> PartialEq<Addr> for &'a Addr

§

fn eq(&self, rhs: &Addr) -> 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.
§

impl PartialEq for Addr

§

fn eq(&self, other: &Addr) -> 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.
§

impl PartialOrd for Addr

§

fn partial_cmp(&self, other: &Addr) -> 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
§

impl<'a> Prefixer<'a> for Addr

§

fn prefix(&self) -> Vec<Key<'_>>

returns 0 or more namespaces that should be length-prefixed and concatenated for range searches
§

fn joined_prefix(&self) -> Vec<u8>

§

impl<'a> PrimaryKey<'a> for Addr

owned variant.

§

type Prefix = ()

These associated types need to implement Prefixer, so that they can be useful arguments for prefix(), sub_prefix(), and their key-deserializable variants.
§

type SubPrefix = ()

§

type Suffix = Addr

These associated types need to implement KeyDeserialize, so that they can be returned from range_de() and friends.
§

type SuperSuffix = Addr

§

fn key(&self) -> Vec<Key<'_>>

returns a slice of key steps, which can be optionally combined
§

fn joined_key(&self) -> Vec<u8>

§

fn joined_extra_key(&self, key: &[u8]) -> Vec<u8>

§

impl Serialize for Addr

§

fn serialize<__S>( &self, __serializer: __S, ) -> Result<<__S as Serializer>::Ok, <__S as Serializer>::Error>
where __S: Serializer,

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

impl Eq for Addr

§

impl StructuralPartialEq for Addr

Auto Trait Implementations§

§

impl Freeze for Addr

§

impl RefUnwindSafe for Addr

§

impl Send for Addr

§

impl Sync for Addr

§

impl Unpin for Addr

§

impl UnwindSafe for Addr

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
§

impl<U> As for U

§

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

source§

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

source§

fn __clone_box(&self, _: Private) -> *mut ()

§

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

§

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

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

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

§

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

Checks if this value is equivalent to the given key. 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> IntoEither for T

source§

fn into_either(self, into_left: bool) -> Either<Self, Self>

Converts self into a Left variant of Either<Self, Self> if into_left is true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
where F: FnOnce(&Self) -> bool,

Converts self into a Left variant of Either<Self, Self> if into_left(&self) returns true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
§

impl<T> Pointable for T

§

const ALIGN: usize = _

The alignment of pointer.
§

type Init = T

The type for initializers.
§

unsafe fn init(init: <T as Pointable>::Init) -> usize

Initializes a with the given initializer. Read more
§

unsafe fn deref<'a>(ptr: usize) -> &'a T

Dereferences the given pointer. Read more
§

unsafe fn deref_mut<'a>(ptr: usize) -> &'a mut T

Mutably dereferences the given pointer. Read more
§

unsafe fn drop(ptr: usize)

Drops the object pointed to by the given pointer. Read more
source§

impl<T> QueryResultExt for T
where T: Serialize,

source§

fn query_result(&self) -> Result<Binary, Error>

Convert the value to its JSON representation
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.
§

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

§

fn vzip(self) -> V

source§

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