liblisa::value

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§

fn as_value(&self) -> Value<'_>

Returns a reference to the value as a Value.

Provided Methods§

fn unwrap_num(&self) -> u64

If the value is an integer, returns the integer. Otherwise, panics.

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

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

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.

Implementations on Foreign Types§

§

impl AsValue for u64

§

fn as_value(&self) -> Value<'_>

Implementors§

§

impl AsValue for OwnedValue

§

impl AsValue for Value<'_>