JsonValueExt

Trait JsonValueExt 

Source
pub trait JsonValueExt {
Show 20 methods // Required methods fn remove(&mut self, property_name: &str) -> Result<JsonValue, Error>; fn remove_into<K: DeserializeOwned>( &mut self, property_name: &str, ) -> Result<K, Error>; fn insert( &mut self, property_name: String, value: JsonValue, ) -> Result<(), Error>; fn push(&mut self, value: JsonValue) -> Result<(), Error>; fn get_string(&self, property_name: &str) -> Result<&str, Error>; fn get_i64(&self, property_name: &str) -> Result<i64, Error>; fn get_f64(&self, property_name: &str) -> Result<f64, Error>; fn get_u8(&self, property_name: &str) -> Result<u8, Error>; fn get_u32(&self, property_name: &str) -> Result<u32, Error>; fn get_u64(&self, property_name: &str) -> Result<u64, Error>; fn get_bytes(&self, property_name: &str) -> Result<Vec<u8>, Error>; fn get_value_mut( &mut self, string_path: &str, ) -> Result<&mut JsonValue, Error>; fn get_value(&self, string_path: &str) -> Result<&JsonValue, Error>; fn get_value_by_path( &self, path: &[JsonPathStep], ) -> Result<&JsonValue, Error>; fn get_value_by_path_mut( &mut self, path: &[JsonPathStep], ) -> Result<&mut JsonValue, Error>; fn remove_u32(&mut self, property_name: &str) -> Result<u32, Error>; fn add_protocol_version( &mut self, property_name: &str, protocol_version: u32, ) -> Result<(), ProtocolError>; fn insert_with_path( &mut self, path: &str, value: JsonValue, ) -> Result<(), Error>; fn remove_value_at_path_into<K: DeserializeOwned>( &mut self, property_name: &str, ) -> Result<K, Error>; fn get_bool(&self, property_name: &str) -> Result<bool, Error>;
}
Expand description

JsonValueExt contains a set of helper methods that simplify work with JsonValue

Required Methods§

Source

fn remove(&mut self, property_name: &str) -> Result<JsonValue, Error>

assumes the Json Value is a map and tries to remove the given property

Source

fn remove_into<K: DeserializeOwned>( &mut self, property_name: &str, ) -> Result<K, Error>

assumes the Json Value is a map and tries to remove the given property and deserialize into the provided type

Source

fn insert( &mut self, property_name: String, value: JsonValue, ) -> Result<(), Error>

assumes the Json Value is a map and tries to insert the given value under given property

Source

fn push(&mut self, value: JsonValue) -> Result<(), Error>

assumes the Json Value is an array and tries to add value to the array

Source

fn get_string(&self, property_name: &str) -> Result<&str, Error>

Source

fn get_i64(&self, property_name: &str) -> Result<i64, Error>

Source

fn get_f64(&self, property_name: &str) -> Result<f64, Error>

Source

fn get_u8(&self, property_name: &str) -> Result<u8, Error>

Source

fn get_u32(&self, property_name: &str) -> Result<u32, Error>

Source

fn get_u64(&self, property_name: &str) -> Result<u64, Error>

Source

fn get_bytes(&self, property_name: &str) -> Result<Vec<u8>, Error>

Source

fn get_value_mut(&mut self, string_path: &str) -> Result<&mut JsonValue, Error>

returns the the mutable JsonValue from provided path. The path is dot-separated string. i.e properties.id

Source

fn get_value(&self, string_path: &str) -> Result<&JsonValue, Error>

returns the the JsonValue from provided path. The path is dot-separated string. i.e properties[0].id

Source

fn get_value_by_path(&self, path: &[JsonPathStep]) -> Result<&JsonValue, Error>

return the JsonValue from from provided path. The path is a slice of JsonPathStep

Source

fn get_value_by_path_mut( &mut self, path: &[JsonPathStep], ) -> Result<&mut JsonValue, Error>

return the mutable JsonValue from from provided path. The path is a slice of JsonPathStep

Source

fn remove_u32(&mut self, property_name: &str) -> Result<u32, Error>

assumes that the JsonValue is a Map and tries to remove the u32

Source

fn add_protocol_version( &mut self, property_name: &str, protocol_version: u32, ) -> Result<(), ProtocolError>

Source

fn insert_with_path( &mut self, path: &str, value: JsonValue, ) -> Result<(), Error>

Insert value under the path. Path is dot-separated string. i.e properties[0].id. If parents don’t exists they will be created

Source

fn remove_value_at_path_into<K: DeserializeOwned>( &mut self, property_name: &str, ) -> Result<K, Error>

Removes data from given path and tries deserialize it into provided type

Source

fn get_bool(&self, property_name: &str) -> Result<bool, Error>

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.

Implementors§