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
- Use
Addr::unchecked(input) - Use
let checked: Addr = deps.api.addr_validate(input)? - Use
let checked: Addr = deps.api.addr_humanize(canonical_addr)? - Deserialize from JSON. This must only be done from JSON that was validated before
such as a contract’s state.
Addrmust 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
impl Addr
pub fn unchecked(input: impl Into<String>) -> 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] ⓘ
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
pub fn into_string(self) -> String
Utility for explicit conversion to String.
Trait Implementations§
§impl<'a> Bounder<'a> for &'a Addr
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<'a> Bounder<'a> for Addr
fn inclusive_bound(self) -> Option<Bound<'a, Addr>>
fn exclusive_bound(self) -> Option<Bound<'a, Addr>>
§impl<'de> Deserialize<'de> for Addr
impl<'de> Deserialize<'de> for Addr
§fn deserialize<__D>(
__deserializer: __D,
) -> Result<Addr, <__D as Deserializer<'de>>::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(
__deserializer: __D,
) -> Result<Addr, <__D as Deserializer<'de>>::Error>where
__D: Deserializer<'de>,
§impl JsonSchema for Addr
impl JsonSchema for Addr
§fn schema_name() -> String
fn schema_name() -> String
§fn schema_id() -> Cow<'static, str>
fn schema_id() -> Cow<'static, str>
§fn json_schema(gen: &mut SchemaGenerator) -> Schema
fn json_schema(gen: &mut SchemaGenerator) -> Schema
§fn is_referenceable() -> bool
fn is_referenceable() -> bool
$ref keyword. Read more§impl KeyDeserialize for &Addr
impl KeyDeserialize for &Addr
type Output = Addr
§const KEY_ELEMS: u16 = 1u16
const KEY_ELEMS: u16 = 1u16
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
impl KeyDeserialize for Addr
type Output = Addr
§const KEY_ELEMS: u16 = 1u16
const KEY_ELEMS: u16 = 1u16
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
impl Ord for Addr
§impl PartialOrd for Addr
impl PartialOrd for Addr
§fn partial_cmp(&self, other: &Addr) -> Option<Ordering>
fn partial_cmp(&self, other: &Addr) -> Option<Ordering>
1.0.0 · source§fn le(&self, other: &Rhs) -> bool
fn le(&self, other: &Rhs) -> bool
self and other) and is used by the <=
operator. Read more§impl<'a> PrimaryKey<'a> for Addr
impl<'a> PrimaryKey<'a> for Addr
owned variant.
§type Prefix = ()
type Prefix = ()
Prefixer, so that they can be useful arguments
for prefix(), sub_prefix(), and their key-deserializable variants.type SubPrefix = ()
§type Suffix = Addr
type Suffix = Addr
KeyDeserialize, so that they can be returned from
range_de() and friends.type SuperSuffix = Addr
fn joined_key(&self) -> Vec<u8>
fn joined_extra_key(&self, key: &[u8]) -> Vec<u8>
§impl Serialize for Addr
impl Serialize for Addr
§fn serialize<__S>(
&self,
__serializer: __S,
) -> Result<<__S as Serializer>::Ok, <__S as Serializer>::Error>where
__S: Serializer,
fn serialize<__S>(
&self,
__serializer: __S,
) -> Result<<__S as Serializer>::Ok, <__S as Serializer>::Error>where
__S: Serializer,
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§
§impl<U> As for U
impl<U> As for U
§fn as_<T>(self) -> Twhere
T: CastFrom<U>,
fn as_<T>(self) -> Twhere
T: CastFrom<U>,
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 moresource§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,
source§default unsafe fn clone_to_uninit(&self, dst: *mut T)
default unsafe fn clone_to_uninit(&self, dst: *mut T)
clone_to_uninit)§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
source§impl<T> IntoEither for T
impl<T> IntoEither for T
source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
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 moresource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
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