pub trait Json: Sized + Eq {
type MetaData: Clone + Sync + Send;
type Number: Number;
type String: Eq + Deref<Target = str> + for<'a> From<&'a str>;
type Array: Get<usize, Item = Self> + Len + Iter + IntoIterator<Item = Self>;
type Key: Key<Self::MetaData>;
type Object: Keyed<Key = Self::Key, Item = Self> + Len + for<'a> Get<&'a str> + for<'a> GetKeyValue<&'a str> + MapIter + IntoIterator<Item = (Self::Key, Self)>;
Show 31 methods
// Required methods
fn as_value_ref(&self) -> ValueRef<'_, Self>;
fn as_value_mut(&mut self) -> ValueMut<'_, Self>;
fn into_parts(self) -> (Value<Self>, Self::MetaData);
fn metadata(&self) -> &Self::MetaData;
fn as_pair_mut(&mut self) -> (ValueMut<'_, Self>, &Self::MetaData);
// Provided methods
fn into_value(self) -> Value<Self> { ... }
fn as_pair(&self) -> (ValueRef<'_, Self>, &Self::MetaData) { ... }
fn is_null(&self) -> bool { ... }
fn is_empty_array(&self) -> bool { ... }
fn is_empty_object(&self) -> bool { ... }
fn is_empty_array_or_object(&self) -> bool { ... }
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 { ... }
fn as_bool(&self) -> Option<bool> { ... }
fn as_number(&self) -> Option<&Self::Number> { ... }
fn as_u32(&self) -> Option<u32> { ... }
fn as_u64(&self) -> Option<u64> { ... }
fn as_i32(&self) -> Option<i32> { ... }
fn as_i64(&self) -> Option<i64> { ... }
fn as_f32(&self) -> Option<f32> { ... }
fn as_f32_lossy(&self) -> Option<f32> { ... }
fn as_f64(&self) -> Option<f64> { ... }
fn as_f64_lossy(&self) -> Option<f64> { ... }
fn as_str(&self) -> Option<&str> { ... }
fn as_array(&self) -> Option<&Self::Array> { ... }
fn as_array_mut(&mut self) -> Option<&mut Self::Array> { ... }
fn as_object(&self) -> Option<&Self::Object> { ... }
fn as_object_mut(&mut self) -> Option<&mut Self::Object> { ... }
}Expand description
JSON value attached to some metadata.
Required Associated Types§
Required Methods§
Sourcefn as_value_ref(&self) -> ValueRef<'_, Self>
fn as_value_ref(&self) -> ValueRef<'_, Self>
Returns a reference to the actual JSON value (without the metadata).
Sourcefn as_value_mut(&mut self) -> ValueMut<'_, Self>
fn as_value_mut(&mut self) -> ValueMut<'_, Self>
Returns a mutable reference to the actual JSON value (without the metadata).
Sourcefn into_parts(self) -> (Value<Self>, Self::MetaData)
fn into_parts(self) -> (Value<Self>, Self::MetaData)
Transforms this JSON value into a Value and MetaData.
Sourcefn metadata(&self) -> &Self::MetaData
fn metadata(&self) -> &Self::MetaData
Returns a reference to the metadata associated to the JSON value.
Sourcefn as_pair_mut(&mut self) -> (ValueMut<'_, Self>, &Self::MetaData)
fn as_pair_mut(&mut self) -> (ValueMut<'_, Self>, &Self::MetaData)
Returns a pair containing a mutable reference to the JSON value and a reference to its metadata.
Provided Methods§
Sourcefn into_value(self) -> Value<Self>
fn into_value(self) -> Value<Self>
Transforms this JSON value into a Value.
Sourcefn as_pair(&self) -> (ValueRef<'_, Self>, &Self::MetaData)
fn as_pair(&self) -> (ValueRef<'_, Self>, &Self::MetaData)
Returns a pair containing a reference to the JSON value and a reference to its metadata.
Sourcefn is_empty_array(&self) -> bool
fn is_empty_array(&self) -> bool
Checks if the value is an empty array.
Sourcefn is_empty_object(&self) -> bool
fn is_empty_object(&self) -> bool
Checks if the value is an empty object.
Sourcefn is_empty_array_or_object(&self) -> bool
fn is_empty_array_or_object(&self) -> bool
Checks if the value is an empty array or empty object.
Sourcefn is_bool(&self) -> bool
fn is_bool(&self) -> bool
Returns true if the value is a boolean. Returns false otherwise.
For any value on which is_bool returns true,
as_bool is guaranteed to return the boolean value.
Sourcefn is_number(&self) -> bool
fn is_number(&self) -> bool
Returns true if the value is a number. Returns false otherwise.
For any value on which is_number returns true,
as_number is guaranteed to return the number value.
Sourcefn is_string(&self) -> bool
fn is_string(&self) -> bool
Returns true if the value is a string.
Returns false otherwise.
For any value on which is_string returns true,
as_str is guaranteed to return the string value.
Sourcefn is_array(&self) -> bool
fn is_array(&self) -> bool
Returns true if the value is an array.
Returns false otherwise.
For any value on which is_array returns true,
as_array is guaranteed to return the array value.
Sourcefn is_object(&self) -> bool
fn is_object(&self) -> bool
Returns true if the value is an object.
Returns false otherwise.
For any value on which is_object returns true,
as_object is guaranteed to return the object value.
Sourcefn as_bool(&self) -> Option<bool>
fn as_bool(&self) -> Option<bool>
If the value is a boolean, returns the associated bool.
Returns None otherwise.
Sourcefn as_number(&self) -> Option<&Self::Number>
fn as_number(&self) -> Option<&Self::Number>
If the value is a number, returns a reference to it.
Returns None otherwise.
Sourcefn as_u32(&self) -> Option<u32>
fn as_u32(&self) -> Option<u32>
Returns this number as an u32 if it can be exactly represented as such.
Sourcefn as_u64(&self) -> Option<u64>
fn as_u64(&self) -> Option<u64>
Returns this number as an u64 if it can be exactly represented as such.
Sourcefn as_i32(&self) -> Option<i32>
fn as_i32(&self) -> Option<i32>
Returns this number as an i32 if it can be exactly represented as such.
Sourcefn as_i64(&self) -> Option<i64>
fn as_i64(&self) -> Option<i64>
Returns this number as an i64 if it can be exactly represented as such.
Sourcefn as_f32(&self) -> Option<f32>
fn as_f32(&self) -> Option<f32>
Returns this number as an f32 if it can be exactly represented as such.
Sourcefn as_f32_lossy(&self) -> Option<f32>
fn as_f32_lossy(&self) -> Option<f32>
Returns this number as an f32 if it is a number, potentially losing precision in the process.
Sourcefn as_f64(&self) -> Option<f64>
fn as_f64(&self) -> Option<f64>
Returns this number as an f64 if it can be exactly represented as such.
Sourcefn as_f64_lossy(&self) -> Option<f64>
fn as_f64_lossy(&self) -> Option<f64>
Returns this number as an f64 if it is a number, potentially losing precision in the process.
Sourcefn as_str(&self) -> Option<&str>
fn as_str(&self) -> Option<&str>
If the value is a string, returns its associated str.
Returns None otherwise.
Sourcefn as_array(&self) -> Option<&Self::Array>
fn as_array(&self) -> Option<&Self::Array>
If the value is an array, returns a reference to it.
Returns None otherwise.
Sourcefn as_array_mut(&mut self) -> Option<&mut Self::Array>
fn as_array_mut(&mut self) -> Option<&mut Self::Array>
If the value is an array, returns a mutable reference to it.
Returns None otherwise.
Sourcefn as_object(&self) -> Option<&Self::Object>
fn as_object(&self) -> Option<&Self::Object>
If the value is an object, returns a reference to it.
Returns None otherwise.
Sourcefn as_object_mut(&mut self) -> Option<&mut Self::Object>
fn as_object_mut(&mut self) -> Option<&mut Self::Object>
If the value is an object, returns a mutable reference to it.
Returns None otherwise.
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.