Struct soroban_sdk::FixedBinary
source · [−]#[repr(transparent)]pub struct FixedBinary<const N: usize>(_);
Expand description
FixedBinary is a contiguous fixed-size array type containing u8
s.
The array is stored in the Host and available to the Guest through the functions defined on Binary.
Binary values can be stored as ContractData, or in other types like Vec, Map, etc.
Examples
FixedBinary values can be created from arrays:
use soroban_sdk::{Binary, FixedBinary, Env};
let env = Env::default();
let bin = FixedBinary::from_array(&env, [0; 32]);
assert_eq!(bin.len(), 32);
FixedBinary and Binary values are convertible:
use soroban_sdk::{Binary, FixedBinary, Env};
let env = Env::default();
let bin = Binary::from_slice(&env, &[0; 32]);
let bin: FixedBinary<32> = bin.try_into().expect("bin to have length 32");
assert_eq!(bin.len(), 32);
Implementations
sourceimpl<const N: usize> FixedBinary<N>
impl<const N: usize> FixedBinary<N>
pub fn from_array(env: &Env, items: [u8; N]) -> FixedBinary<N>
pub fn set(&mut self, i: u32, v: u8)
pub fn get(&self, i: u32) -> Option<u8>
pub fn get_unchecked(&self, i: u32) -> u8
pub fn is_empty(&self) -> bool
pub fn len(&self) -> u32
pub fn first(&self) -> Option<u8>
pub fn first_unchecked(&self) -> u8
pub fn last(&self) -> Option<u8>
pub fn last_unchecked(&self) -> u8
pub fn iter(&self) -> BinIter
Trait Implementations
sourceimpl<const N: usize> AsRef<Binary> for FixedBinary<N>
impl<const N: usize> AsRef<Binary> for FixedBinary<N>
sourceimpl AsRef<FixedBinary<32>> for Account
impl AsRef<FixedBinary<32>> for Account
sourcefn as_ref(&self) -> &FixedBinary<32>
fn as_ref(&self) -> &FixedBinary<32>
Converts this type into a shared reference of the (usually inferred) input type.
sourceimpl<const N: usize> Borrow<Binary> for &FixedBinary<N>
impl<const N: usize> Borrow<Binary> for &FixedBinary<N>
sourceimpl<const N: usize> Borrow<Binary> for &mut FixedBinary<N>
impl<const N: usize> Borrow<Binary> for &mut FixedBinary<N>
sourceimpl<const N: usize> Borrow<Binary> for FixedBinary<N>
impl<const N: usize> Borrow<Binary> for FixedBinary<N>
sourceimpl Borrow<FixedBinary<32>> for &Account
impl Borrow<FixedBinary<32>> for &Account
sourcefn borrow(&self) -> &FixedBinary<32>
fn borrow(&self) -> &FixedBinary<32>
Immutably borrows from an owned value. Read more
sourceimpl Borrow<FixedBinary<32>> for &mut Account
impl Borrow<FixedBinary<32>> for &mut Account
sourcefn borrow(&self) -> &FixedBinary<32>
fn borrow(&self) -> &FixedBinary<32>
Immutably borrows from an owned value. Read more
sourceimpl Borrow<FixedBinary<32>> for Account
impl Borrow<FixedBinary<32>> for Account
sourcefn borrow(&self) -> &FixedBinary<32>
fn borrow(&self) -> &FixedBinary<32>
Immutably borrows from an owned value. Read more
sourceimpl<const N: usize> Clone for FixedBinary<N>
impl<const N: usize> Clone for FixedBinary<N>
sourcefn clone(&self) -> FixedBinary<N>
fn clone(&self) -> FixedBinary<N>
Returns a copy of the value. Read more
1.0.0 · sourcefn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from source
. Read more
sourceimpl<const N: usize> Debug for FixedBinary<N>
impl<const N: usize> Debug for FixedBinary<N>
sourceimpl<const N: usize> From<FixedBinary<N>> for [u8; N]
impl<const N: usize> From<FixedBinary<N>> for [u8; N]
sourcefn from(bin: FixedBinary<N>) -> Self
fn from(bin: FixedBinary<N>) -> Self
Converts to this type from the input type.
sourceimpl<const N: usize> From<FixedBinary<N>> for Binary
impl<const N: usize> From<FixedBinary<N>> for Binary
sourcefn from(v: FixedBinary<N>) -> Self
fn from(v: FixedBinary<N>) -> Self
Converts to this type from the input type.
sourceimpl<const N: usize> From<FixedBinary<N>> for EnvVal
impl<const N: usize> From<FixedBinary<N>> for EnvVal
sourcefn from(v: FixedBinary<N>) -> Self
fn from(v: FixedBinary<N>) -> Self
Converts to this type from the input type.
sourceimpl<const N: usize> From<FixedBinary<N>> for EnvVal<Env, Object>
impl<const N: usize> From<FixedBinary<N>> for EnvVal<Env, Object>
sourcefn from(v: FixedBinary<N>) -> Self
fn from(v: FixedBinary<N>) -> Self
Converts to this type from the input type.
sourceimpl<const N: usize> From<FixedBinary<N>> for RawVal
impl<const N: usize> From<FixedBinary<N>> for RawVal
sourcefn from(v: FixedBinary<N>) -> Self
fn from(v: FixedBinary<N>) -> Self
Converts to this type from the input type.
sourceimpl<const N: usize> IntoIterator for FixedBinary<N>
impl<const N: usize> IntoIterator for FixedBinary<N>
sourceimpl<const N: usize> IntoVal<Env, FixedBinary<N>> for [u8; N]
impl<const N: usize> IntoVal<Env, FixedBinary<N>> for [u8; N]
fn into_val(self, env: &Env) -> FixedBinary<N>
fn into_env_val(self, env: &E) -> EnvVal<E, V>
sourceimpl<const N: usize> Ord for FixedBinary<N>
impl<const N: usize> Ord for FixedBinary<N>
1.21.0 · sourcefn max(self, other: Self) -> Self
fn max(self, other: Self) -> Self
Compares and returns the maximum of two values. Read more
1.21.0 · sourcefn min(self, other: Self) -> Self
fn min(self, other: Self) -> Self
Compares and returns the minimum of two values. Read more
1.50.0 · sourcefn clamp(self, min: Self, max: Self) -> Self where
Self: PartialOrd<Self>,
fn clamp(self, min: Self, max: Self) -> Self where
Self: PartialOrd<Self>,
Restrict a value to a certain interval. Read more
sourceimpl<const N: usize> PartialEq<FixedBinary<N>> for FixedBinary<N>
impl<const N: usize> PartialEq<FixedBinary<N>> for FixedBinary<N>
sourceimpl<const N: usize> PartialOrd<FixedBinary<N>> for FixedBinary<N>
impl<const N: usize> PartialOrd<FixedBinary<N>> for FixedBinary<N>
sourcefn partial_cmp(&self, other: &Self) -> Option<Ordering>
fn partial_cmp(&self, other: &Self) -> Option<Ordering>
This method returns an ordering between self
and other
values if one exists. Read more
1.0.0 · sourcefn lt(&self, other: &Rhs) -> bool
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 · sourcefn le(&self, other: &Rhs) -> bool
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
sourceimpl<const N: usize> TryFrom<&FixedBinary<N>> for ScVal
impl<const N: usize> TryFrom<&FixedBinary<N>> for ScVal
type Error = ConversionError
type Error = ConversionError
The type returned in the event of a conversion error.
sourcefn try_from(v: &FixedBinary<N>) -> Result<Self, Self::Error>
fn try_from(v: &FixedBinary<N>) -> Result<Self, Self::Error>
Performs the conversion.
sourceimpl<const N: usize> TryFrom<Binary> for FixedBinary<N>
impl<const N: usize> TryFrom<Binary> for FixedBinary<N>
sourceimpl<const N: usize> TryFrom<EnvVal<Env, Object>> for FixedBinary<N>
impl<const N: usize> TryFrom<EnvVal<Env, Object>> for FixedBinary<N>
sourceimpl<const N: usize> TryFrom<FixedBinary<N>> for ScVal
impl<const N: usize> TryFrom<FixedBinary<N>> for ScVal
type Error = ConversionError
type Error = ConversionError
The type returned in the event of a conversion error.
sourcefn try_from(v: FixedBinary<N>) -> Result<Self, Self::Error>
fn try_from(v: FixedBinary<N>) -> Result<Self, Self::Error>
Performs the conversion.
sourceimpl<const N: usize> TryIntoVal<Env, FixedBinary<N>> for RawVal
impl<const N: usize> TryIntoVal<Env, FixedBinary<N>> for RawVal
type Error = ConversionError
fn try_into_val(self, env: &Env) -> Result<FixedBinary<N>, Self::Error>
fn try_into_env_val(self, env: &E) -> Result<EnvVal<E, V>, Self::Error>
sourceimpl<const N: usize> TryIntoVal<Env, FixedBinary<N>> for ScVal
impl<const N: usize> TryIntoVal<Env, FixedBinary<N>> for ScVal
type Error = ConversionError
fn try_into_val(self, env: &Env) -> Result<FixedBinary<N>, Self::Error>
fn try_into_env_val(self, env: &E) -> Result<EnvVal<E, V>, Self::Error>
impl<const N: usize> Eq for FixedBinary<N>
Auto Trait Implementations
impl<const N: usize> !RefUnwindSafe for FixedBinary<N>
impl<const N: usize> !Send for FixedBinary<N>
impl<const N: usize> !Sync for FixedBinary<N>
impl<const N: usize> Unpin for FixedBinary<N>
impl<const N: usize> !UnwindSafe for FixedBinary<N>
Blanket Implementations
sourceimpl<T> BorrowMut<T> for T where
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
const: unstable · sourcefn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more