[−][src]Struct cosmwasm_std::Binary
Binary is a wrapper around Vec
This is only needed as serde-json-{core,wasm} has a horrible encoding for Vec
Implementations
impl Binary[src]
pub fn from_base64(encoded: &str) -> StdResult<Self>[src]
take an (untrusted) string and decode it into bytes. fails if it is not valid base64
pub fn to_base64(&self) -> String[src]
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][src]
pub fn to_array<A>(&self) -> StdResult<A> where
A: ByteArray, [src]
A: ByteArray,
Copies content into fixed-sized array.
The result type A: ByteArray is a workaround for
the missing const-generics.
A is a fixed-sized array like [u8; 8].
ByteArray is implemented for [u8; 0] to [u8; 64], such that
we are limited to 64 bytes for now.
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
impl Clone for Binary[src]
impl Debug for Binary[src]
impl Default for Binary[src]
impl Deref for Binary[src]
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.
impl<'de> Deserialize<'de> for Binary[src]
Deserializes as a base64 string
pub fn deserialize<D>(deserializer: D) -> Result<Binary, D::Error> where
D: Deserializer<'de>, [src]
D: Deserializer<'de>,
impl Display for Binary[src]
impl Eq for Binary[src]
impl From<&'_ [u8; 0]> for Binary[src]
impl From<&'_ [u8; 1]> for Binary[src]
impl From<&'_ [u8; 10]> for Binary[src]
impl From<&'_ [u8; 11]> for Binary[src]
impl From<&'_ [u8; 12]> for Binary[src]
impl From<&'_ [u8; 13]> for Binary[src]
impl From<&'_ [u8; 14]> for Binary[src]
impl From<&'_ [u8; 15]> for Binary[src]
impl From<&'_ [u8; 16]> for Binary[src]
impl From<&'_ [u8; 17]> for Binary[src]
impl From<&'_ [u8; 18]> for Binary[src]
impl From<&'_ [u8; 19]> for Binary[src]
impl From<&'_ [u8; 2]> for Binary[src]
impl From<&'_ [u8; 20]> for Binary[src]
impl From<&'_ [u8; 21]> for Binary[src]
impl From<&'_ [u8; 22]> for Binary[src]
impl From<&'_ [u8; 23]> for Binary[src]
impl From<&'_ [u8; 24]> for Binary[src]
impl From<&'_ [u8; 25]> for Binary[src]
impl From<&'_ [u8; 26]> for Binary[src]
impl From<&'_ [u8; 27]> for Binary[src]
impl From<&'_ [u8; 28]> for Binary[src]
impl From<&'_ [u8; 29]> for Binary[src]
impl From<&'_ [u8; 3]> for Binary[src]
impl From<&'_ [u8; 30]> for Binary[src]
impl From<&'_ [u8; 31]> for Binary[src]
impl From<&'_ [u8; 32]> for Binary[src]
impl From<&'_ [u8; 33]> for Binary[src]
impl From<&'_ [u8; 34]> for Binary[src]
impl From<&'_ [u8; 35]> for Binary[src]
impl From<&'_ [u8; 36]> for Binary[src]
impl From<&'_ [u8; 37]> for Binary[src]
impl From<&'_ [u8; 38]> for Binary[src]
impl From<&'_ [u8; 39]> for Binary[src]
impl From<&'_ [u8; 4]> for Binary[src]
impl From<&'_ [u8; 40]> for Binary[src]
impl From<&'_ [u8; 41]> for Binary[src]
impl From<&'_ [u8; 42]> for Binary[src]
impl From<&'_ [u8; 43]> for Binary[src]
impl From<&'_ [u8; 44]> for Binary[src]
impl From<&'_ [u8; 45]> for Binary[src]
impl From<&'_ [u8; 46]> for Binary[src]
impl From<&'_ [u8; 47]> for Binary[src]
impl From<&'_ [u8; 48]> for Binary[src]
impl From<&'_ [u8; 49]> for Binary[src]
impl From<&'_ [u8; 5]> for Binary[src]
impl From<&'_ [u8; 50]> for Binary[src]
impl From<&'_ [u8; 51]> for Binary[src]
impl From<&'_ [u8; 52]> for Binary[src]
impl From<&'_ [u8; 53]> for Binary[src]
impl From<&'_ [u8; 54]> for Binary[src]
impl From<&'_ [u8; 55]> for Binary[src]
impl From<&'_ [u8; 56]> for Binary[src]
impl From<&'_ [u8; 57]> for Binary[src]
impl From<&'_ [u8; 58]> for Binary[src]
impl From<&'_ [u8; 59]> for Binary[src]
impl From<&'_ [u8; 6]> for Binary[src]
impl From<&'_ [u8; 60]> for Binary[src]
impl From<&'_ [u8; 61]> for Binary[src]
impl From<&'_ [u8; 62]> for Binary[src]
impl From<&'_ [u8; 63]> for Binary[src]
impl From<&'_ [u8; 64]> for Binary[src]
impl From<&'_ [u8; 7]> for Binary[src]
impl From<&'_ [u8; 8]> for Binary[src]
impl From<&'_ [u8; 9]> for Binary[src]
impl From<&'_ [u8]> for Binary[src]
impl From<[u8; 0]> for Binary[src]
impl From<[u8; 1]> for Binary[src]
impl From<[u8; 10]> for Binary[src]
impl From<[u8; 11]> for Binary[src]
impl From<[u8; 12]> for Binary[src]
impl From<[u8; 13]> for Binary[src]
impl From<[u8; 14]> for Binary[src]
impl From<[u8; 15]> for Binary[src]
impl From<[u8; 16]> for Binary[src]
impl From<[u8; 17]> for Binary[src]
impl From<[u8; 18]> for Binary[src]
impl From<[u8; 19]> for Binary[src]
impl From<[u8; 2]> for Binary[src]
impl From<[u8; 20]> for Binary[src]
impl From<[u8; 21]> for Binary[src]
impl From<[u8; 22]> for Binary[src]
impl From<[u8; 23]> for Binary[src]
impl From<[u8; 24]> for Binary[src]
impl From<[u8; 25]> for Binary[src]
impl From<[u8; 26]> for Binary[src]
impl From<[u8; 27]> for Binary[src]
impl From<[u8; 28]> for Binary[src]
impl From<[u8; 29]> for Binary[src]
impl From<[u8; 3]> for Binary[src]
impl From<[u8; 30]> for Binary[src]
impl From<[u8; 31]> for Binary[src]
impl From<[u8; 32]> for Binary[src]
impl From<[u8; 33]> for Binary[src]
impl From<[u8; 34]> for Binary[src]
impl From<[u8; 35]> for Binary[src]
impl From<[u8; 36]> for Binary[src]
impl From<[u8; 37]> for Binary[src]
impl From<[u8; 38]> for Binary[src]
impl From<[u8; 39]> for Binary[src]
impl From<[u8; 4]> for Binary[src]
impl From<[u8; 40]> for Binary[src]
impl From<[u8; 41]> for Binary[src]
impl From<[u8; 42]> for Binary[src]
impl From<[u8; 43]> for Binary[src]
impl From<[u8; 44]> for Binary[src]
impl From<[u8; 45]> for Binary[src]
impl From<[u8; 46]> for Binary[src]
impl From<[u8; 47]> for Binary[src]
impl From<[u8; 48]> for Binary[src]
impl From<[u8; 49]> for Binary[src]
impl From<[u8; 5]> for Binary[src]
impl From<[u8; 50]> for Binary[src]
impl From<[u8; 51]> for Binary[src]
impl From<[u8; 52]> for Binary[src]
impl From<[u8; 53]> for Binary[src]
impl From<[u8; 54]> for Binary[src]
impl From<[u8; 55]> for Binary[src]
impl From<[u8; 56]> for Binary[src]
impl From<[u8; 57]> for Binary[src]
impl From<[u8; 58]> for Binary[src]
impl From<[u8; 59]> for Binary[src]
impl From<[u8; 6]> for Binary[src]
impl From<[u8; 60]> for Binary[src]
impl From<[u8; 61]> for Binary[src]
impl From<[u8; 62]> for Binary[src]
impl From<[u8; 63]> for Binary[src]
impl From<[u8; 64]> for Binary[src]
impl From<[u8; 7]> for Binary[src]
impl From<[u8; 8]> for Binary[src]
impl From<[u8; 9]> for Binary[src]
impl From<Binary> for Vec<u8>[src]
impl From<Vec<u8, Global>> for Binary[src]
impl Hash for Binary[src]
pub fn hash<__H: Hasher>(&self, state: &mut __H)[src]
pub fn hash_slice<H>(data: &[Self], state: &mut H) where
H: Hasher, 1.3.0[src]
H: Hasher,
impl JsonSchema for Binary[src]
pub fn schema_name() -> String[src]
pub fn json_schema(gen: &mut SchemaGenerator) -> Schema[src]
pub fn is_referenceable() -> bool[src]
impl PartialEq<&'_ [u8]> for Binary[src]
Implement Binary == &[u8]
pub fn eq(&self, rhs: &&[u8]) -> bool[src]
#[must_use]pub fn ne(&self, other: &Rhs) -> bool1.0.0[src]
impl PartialEq<Binary> for Binary[src]
impl PartialEq<Binary> for Vec<u8>[src]
Implement std::vec::Vec<u8> == encoding::Binary
pub fn eq(&self, rhs: &Binary) -> bool[src]
#[must_use]pub fn ne(&self, other: &Rhs) -> bool1.0.0[src]
impl PartialEq<Binary> for &[u8][src]
Implement &[u8] == Binary
pub fn eq(&self, rhs: &Binary) -> bool[src]
#[must_use]pub fn ne(&self, other: &Rhs) -> bool1.0.0[src]
impl PartialEq<Vec<u8, Global>> for Binary[src]
Implement encoding::Binary == std::vec::Vec<u8>
pub fn eq(&self, rhs: &Vec<u8>) -> bool[src]
#[must_use]pub fn ne(&self, other: &Rhs) -> bool1.0.0[src]
impl Serialize for Binary[src]
Serializes as a base64 string
impl StructuralEq for Binary[src]
impl StructuralPartialEq for Binary[src]
Auto Trait Implementations
impl RefUnwindSafe for Binary[src]
impl Send for Binary[src]
impl Sync for Binary[src]
impl Unpin for Binary[src]
impl UnwindSafe for Binary[src]
Blanket Implementations
impl<T> Any for T where
T: 'static + ?Sized, [src]
T: 'static + ?Sized,
impl<T> Borrow<T> for T where
T: ?Sized, [src]
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized, [src]
T: ?Sized,
pub fn borrow_mut(&mut self) -> &mut T[src]
impl<T> DeserializeOwned for T where
T: for<'de> Deserialize<'de>, [src]
T: for<'de> Deserialize<'de>,
impl<T> From<T> for T[src]
impl<T, U> Into<U> for T where
U: From<T>, [src]
U: From<T>,
impl<T> ToOwned for T where
T: Clone, [src]
T: Clone,
type Owned = T
The resulting type after obtaining ownership.
pub fn to_owned(&self) -> T[src]
pub fn clone_into(&self, target: &mut T)[src]
impl<T> ToString for T where
T: Display + ?Sized, [src]
T: Display + ?Sized,
impl<T, U> TryFrom<U> for T where
U: Into<T>, [src]
U: Into<T>,
type Error = Infallible
The type returned in the event of a conversion error.
pub fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>[src]
impl<T, U> TryInto<U> for T where
U: TryFrom<T>, [src]
U: TryFrom<T>,