Type Alias cosmwasm_std::QueryResponse

source ·
pub type QueryResponse = Binary;

Aliased Type§

struct QueryResponse(/* private fields */);

Implementations

source§

impl Binary

source

pub const fn new(data: Vec<u8>) -> Self

Creates a new Binary containing the given data.

source

pub fn from_base64(encoded: &str) -> StdResult<Self>

take an (untrusted) string and decode it into bytes. fails if it is not valid base64

source

pub fn to_base64(&self) -> String

encode to base64 string (guaranteed to be success as we control the data inside). this returns normalized form (with trailing = if needed)

source

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

source

pub fn to_array<const LENGTH: usize>(&self) -> StdResult<[u8; LENGTH]>

Copies content into fixed-sized array.

§Examples

Copy to array of explicit length

let binary = Binary::from(&[0xfb, 0x1f, 0x37]);
let array: [u8; 3] = binary.to_array().unwrap();
assert_eq!(array, [0xfb, 0x1f, 0x37]);

Copy to integer

let binary = Binary::from(&[0x8b, 0x67, 0x64, 0x84, 0xb5, 0xfb, 0x1f, 0x37]);
let num = u64::from_be_bytes(binary.to_array().unwrap());
assert_eq!(num, 10045108015024774967);

Trait Implementations

source§

impl AsRef<[u8]> for Binary

source§

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

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

impl Clone for Binary

source§

fn clone(&self) -> Binary

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 Binary

source§

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

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

impl Default for Binary

source§

fn default() -> Binary

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

impl Deref for Binary

Just like Vec, Binary is a smart pointer to u8. This implements *binary for us and allows us to do &*binary, returning a &[u8] from a &Binary. With deref coercions, this allows us to use &binary whenever a &[u8] is required.

source§

type Target = [u8]

The resulting type after dereferencing.
source§

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

Dereferences the value.
source§

impl<'de> Deserialize<'de> for Binary

Deserializes as a base64 string

source§

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

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

impl Display for Binary

source§

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

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

impl From<&[u8]> for Binary

source§

fn from(binary: &[u8]) -> Self

Converts to this type from the input type.
source§

impl<const LENGTH: usize> From<&[u8; LENGTH]> for Binary

source§

fn from(source: &[u8; LENGTH]) -> Self

Converts to this type from the input type.
source§

impl<const LENGTH: usize> From<[u8; LENGTH]> for Binary

source§

fn from(source: [u8; LENGTH]) -> Self

Converts to this type from the input type.
source§

impl From<CanonicalAddr> for Binary

source§

fn from(source: CanonicalAddr) -> Binary

Converts to this type from the input type.
source§

impl From<HexBinary> for Binary

source§

fn from(original: HexBinary) -> Binary

Converts to this type from the input type.
source§

impl From<StdAck> for Binary

source§

fn from(original: StdAck) -> Binary

Converts to this type from the input type.
source§

impl From<Vec<u8>> for Binary

source§

fn from(vec: Vec<u8>) -> Self

Converts to this type from the input type.
source§

impl Hash for Binary

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 JsonSchema for Binary

source§

fn schema_name() -> String

The name of the generated JSON Schema. Read more
source§

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

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

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

Generates a JSON Schema for this type. Read more
source§

fn is_referenceable() -> bool

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

impl Ord for Binary

source§

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

Implement Binary == &[u8]

source§

fn eq(&self, rhs: &&[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<const LENGTH: usize> PartialEq<&[u8; LENGTH]> for Binary

Implement Binary == &[u8; LENGTH]

source§

fn eq(&self, rhs: &&[u8; LENGTH]) -> 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<const LENGTH: usize> PartialEq<[u8; LENGTH]> for Binary

Implement Binary == [u8; LENGTH]

source§

fn eq(&self, rhs: &[u8; LENGTH]) -> 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<CanonicalAddr> for Binary

Implement Binary == CanonicalAddr

source§

fn eq(&self, rhs: &CanonicalAddr) -> 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<Vec<u8>> for Binary

Implement encoding::Binary == alloc::vec::Vec<u8>

source§

fn eq(&self, rhs: &Vec<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 for Binary

source§

fn eq(&self, other: &Binary) -> 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 for Binary

source§

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

Serializes as a base64 string

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 Eq for Binary

source§

impl StructuralPartialEq for Binary