Type Alias cosmwasm_std::QueryResponse
source · pub type QueryResponse = Binary;
Aliased Type§
struct QueryResponse(/* private fields */);
Implementations
source§impl Binary
impl Binary
sourcepub fn from_base64(encoded: &str) -> StdResult<Self>
pub fn from_base64(encoded: &str) -> StdResult<Self>
take an (untrusted) string and decode it into bytes. fails if it is not valid base64
sourcepub fn to_base64(&self) -> String
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)
pub fn as_slice(&self) -> &[u8] ⓘ
sourcepub fn to_array<const LENGTH: usize>(&self) -> StdResult<[u8; LENGTH]>
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 Deref for Binary
impl Deref for Binary
Just like Vec*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§impl<'de> Deserialize<'de> for Binary
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>,
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 From<CanonicalAddr> for Binary
impl From<CanonicalAddr> for Binary
source§fn from(source: CanonicalAddr) -> Binary
fn from(source: CanonicalAddr) -> Binary
Converts to this type from the input type.
source§impl JsonSchema for Binary
impl JsonSchema for Binary
source§fn schema_name() -> String
fn schema_name() -> String
The name of the generated JSON Schema. Read more
source§fn schema_id() -> Cow<'static, str>
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
fn json_schema(gen: &mut SchemaGenerator) -> Schema
Generates a JSON Schema for this type. Read more
source§fn is_referenceable() -> bool
fn is_referenceable() -> bool
Whether JSON Schemas generated for this type should be re-used where possible using the
$ref
keyword. Read moresource§impl Ord for Binary
impl Ord for Binary
source§impl<const LENGTH: usize> PartialEq<&[u8; LENGTH]> for Binary
impl<const LENGTH: usize> PartialEq<&[u8; LENGTH]> for Binary
Implement Binary == &[u8; LENGTH]
source§impl PartialEq<CanonicalAddr> for Binary
impl PartialEq<CanonicalAddr> for Binary
Implement Binary == CanonicalAddr