Trait ObjectRef

Source
pub trait ObjectRef<'a>: Copy {
    type JsonRef: JsonRef<'a>;

    // Required methods
    fn len(self) -> usize;
    fn get(self, key: &str) -> Option<Self::JsonRef>;
    fn list(self) -> Vec<(&'a str, Self::JsonRef)>;
    fn list_value(self) -> Vec<Self::JsonRef>;

    // Provided method
    fn is_empty(self) -> bool { ... }
}
Expand description

A trait for borrowed JSON objects.

Required Associated Types§

Source

type JsonRef: JsonRef<'a>

The type of borrowed JSON values.

Required Methods§

Source

fn len(self) -> usize

Source

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

Returns the value associated with the given key.

Source

fn list(self) -> Vec<(&'a str, Self::JsonRef)>

Returns all entries in the object.

Source

fn list_value(self) -> Vec<Self::JsonRef>

Returns all values in the object.

Provided Methods§

Source

fn is_empty(self) -> bool

Returns true if the array is empty.

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§

Source§

impl<'a> ObjectRef<'a> for &'a Map<String, Value>

Source§

type JsonRef = &'a Value

Source§

fn len(self) -> usize

Source§

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

Source§

fn list(self) -> Vec<(&'a str, Self::JsonRef)>

Source§

fn list_value(self) -> Vec<Self::JsonRef>

Implementors§