Skip to main content

CborValueExt

Trait CborValueExt 

Source
pub trait CborValueExt {
    // Required methods
    fn as_str(&self) -> Option<&str>;
    fn as_i64(&self) -> Option<i64>;
    fn as_u64(&self) -> Option<u64>;
    fn as_f64(&self) -> Option<f64>;
    fn get(&self, key: &str) -> Option<&Value>;
    fn get_mut(&mut self, key: &str) -> Option<&mut Value>;
}

Required Methods§

Source

fn as_str(&self) -> Option<&str>

Borrow the inner string if this is a Text value.

Source

fn as_i64(&self) -> Option<i64>

Try to extract an i64. Returns None if the value is not an integer or doesn’t fit.

Source

fn as_u64(&self) -> Option<u64>

Try to extract a u64. Returns None if the value is not an integer or doesn’t fit.

Source

fn as_f64(&self) -> Option<f64>

Borrow the inner f64 if this is a Float value.

Source

fn get(&self, key: &str) -> Option<&Value>

Look up a value in a Map by string key. Returns None if the value isn’t a map or the key isn’t present.

Source

fn get_mut(&mut self, key: &str) -> Option<&mut Value>

Same as get, but returns a mutable reference.

Dyn Compatibility§

This trait is dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety".

Implementations on Foreign Types§

Source§

impl CborValueExt for Value

Source§

fn as_str(&self) -> Option<&str>

Source§

fn as_i64(&self) -> Option<i64>

Source§

fn as_u64(&self) -> Option<u64>

Source§

fn as_f64(&self) -> Option<f64>

Source§

fn get(&self, key: &str) -> Option<&Value>

Source§

fn get_mut(&mut self, key: &str) -> Option<&mut Value>

Implementors§