Enum Value
pub enum Value<'a> {
Num(u64),
Bytes(&'a [u8]),
}
Expand description
A values that stores its byte data as a &[u8]
.
Variants§
Implementations§
§impl Value<'_>
impl Value<'_>
pub fn to_le_bytes(&self) -> Vec<u8>
pub fn to_le_bytes(&self) -> Vec<u8>
Converts the value to little-endian bytes.
pub fn select_byte(&self, index: usize) -> u8
pub fn select_byte(&self, index: usize) -> u8
Returns the byte at position index
in the value.
For integers, returns (val >> (index * 8)) as u8
pub fn xor<T>(&self, b: &Value<'_>, f: impl FnMut(&Value<'_>) -> T) -> T
pub fn xor<T>(&self, b: &Value<'_>, f: impl FnMut(&Value<'_>) -> T) -> T
Computes the XOR of this value and b
.
The result is provided to f
.
Trait Implementations§
§impl AsValue for Value<'_>
impl AsValue for Value<'_>
§fn unwrap_num(&self) -> u64
fn unwrap_num(&self) -> u64
If the value is an integer, returns the integer.
Otherwise, panics.
§fn unwrap_bytes(&self) -> &[u8] ⓘ
fn unwrap_bytes(&self) -> &[u8] ⓘ
If the value is Byte data, returns a reference to the bytestring.
Otherwise, panics.
§fn interpret_as_bool(&self) -> bool
fn interpret_as_bool(&self) -> bool
If the value is an integer, returns true if and only if the integer is non-zero.
Otherwise, panics.
§fn to_owned_value(&self) -> OwnedValue
fn to_owned_value(&self) -> OwnedValue
Converts the value to an
OwnedValue
.§impl Equivalent<OwnedValue> for Value<'_>
impl Equivalent<OwnedValue> for Value<'_>
§fn equivalent(&self, key: &OwnedValue) -> bool
fn equivalent(&self, key: &OwnedValue) -> bool
Checks if this value is equivalent to the given key. Read more
§impl Equivalent<Value<'_>> for OwnedValue
impl Equivalent<Value<'_>> for OwnedValue
§fn equivalent(&self, key: &Value<'_>) -> bool
fn equivalent(&self, key: &Value<'_>) -> bool
Checks if this value is equivalent to the given key. Read more
§impl<'a> From<Value<'a>> for OwnedValue
impl<'a> From<Value<'a>> for OwnedValue
§impl PartialEq<OwnedValue> for Value<'_>
impl PartialEq<OwnedValue> for Value<'_>
§impl<'a> PartialEq<Value<'a>> for OwnedValue
impl<'a> PartialEq<Value<'a>> for OwnedValue
impl<'a> Copy for Value<'a>
impl<'a> Eq for Value<'a>
impl<'a> StructuralPartialEq for Value<'a>
Auto Trait Implementations§
impl<'a> Freeze for Value<'a>
impl<'a> RefUnwindSafe for Value<'a>
impl<'a> Send for Value<'a>
impl<'a> Sync for Value<'a>
impl<'a> Unpin for Value<'a>
impl<'a> UnwindSafe for Value<'a>
Blanket Implementations§
source§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
Mutably borrows from an owned value. Read more
source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
source§unsafe fn clone_to_uninit(&self, dst: *mut T)
unsafe fn clone_to_uninit(&self, dst: *mut T)
🔬This is a nightly-only experimental API. (
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
Checks if this value is equivalent to the given key. Read more
§impl<T> Identity for Twhere
T: ?Sized,
impl<T> Identity for Twhere
T: ?Sized,
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>
Converts
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>
Converts
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