pub trait JsonRef<'a>: Copy + Debug {
type Owned: Json<Borrowed<'a> = Self> + 'a;
type Array: ArrayRef<'a, JsonRef = Self>;
type Object: ObjectRef<'a, JsonRef = Self>;
Show 13 methods
// Required methods
fn to_owned(self) -> Self::Owned;
fn null() -> Self;
fn as_bool(self) -> Option<bool>;
fn as_number(self) -> Option<Number>;
fn as_str(self) -> Option<&'a str>;
fn as_array(self) -> Option<Self::Array>;
fn as_object(self) -> Option<Self::Object>;
fn is_null(self) -> bool;
// Provided methods
fn is_bool(self) -> bool { ... }
fn is_number(self) -> bool { ... }
fn is_string(self) -> bool { ... }
fn is_array(self) -> bool { ... }
fn is_object(self) -> bool { ... }
}
Expand description
A trait for borrowed JSON values.
Required Associated Types§
Required Methods§
Sourcefn as_bool(self) -> Option<bool>
fn as_bool(self) -> Option<bool>
If the JSON is a boolean, returns the associated bool. Returns None
otherwise.
Sourcefn as_number(self) -> Option<Number>
fn as_number(self) -> Option<Number>
If the JSON is a number, returns the associated number. Returns None
otherwise.
Sourcefn as_str(self) -> Option<&'a str>
fn as_str(self) -> Option<&'a str>
If the JSON is a string, returns the associated string. Returns None
otherwise.
Sourcefn as_array(self) -> Option<Self::Array>
fn as_array(self) -> Option<Self::Array>
If the JSON is an array, returns the associated array. Returns None
otherwise.
Provided Methods§
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.