Trait AsValue
pub trait AsValue:
Debug
+ Hash
+ PartialEq<OwnedValue> {
// Required method
fn as_value(&self) -> Value<'_>;
// Provided methods
fn unwrap_num(&self) -> u64 { ... }
fn unwrap_bytes(&self) -> &[u8] ⓘ { ... }
fn interpret_as_bool(&self) -> bool { ... }
fn to_owned_value(&self) -> OwnedValue { ... }
}Expand description
Trait that is implemented by any type that can be converted into a Value.
Required Methods§
Provided Methods§
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.
Dyn Compatibility§
This trait is not dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.