Trait generic_json::Json [−][src]
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
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);
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.
Associated Types
Metadata type attached to each value.
The metadata should be ignored during comparison/ordering/hashing of JSON values.
Required methods
fn as_value_ref(&self) -> ValueRef<'_, Self>
fn as_value_ref(&self) -> ValueRef<'_, Self>
Returns a reference to the actual JSON value (without the metadata).
fn 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).
Transforms this JSON value into a Value and MetaData.
Returns a reference to the metadata associated to the JSON value.
Provided methods
fn into_value(self) -> Value<Self>
fn into_value(self) -> Value<Self>
Transforms this JSON value into a Value.
Returns a pair containing a reference to the JSON value and a reference to its metadata.
fn is_empty_array(&self) -> bool
fn is_empty_array(&self) -> bool
Checks if the value is an empty array.
fn is_empty_object(&self) -> bool
fn is_empty_object(&self) -> bool
Checks if the value is an empty object.
fn 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.
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.
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.
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.
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.
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.
If the value is a boolean, returns the associated bool.
Returns None otherwise.
If the value is a number, returns a reference to it.
Returns None otherwise.
Returns this number as an u32 if it can be exactly represented as such.
Returns this number as an u64 if it can be exactly represented as such.
Returns this number as an i32 if it can be exactly represented as such.
Returns this number as an i64 if it can be exactly represented as such.
Returns this number as an f32 if it can be exactly represented as such.
fn 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.
Returns this number as an f64 if it can be exactly represented as such.
fn 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.
If the value is a string, returns its associated str.
Returns None otherwise.
If the value is an array, returns a reference to it.
Returns None otherwise.
fn 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.
If the value is an object, returns a reference to it.
Returns None otherwise.
fn 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.
