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§
Sourcefn remove(&mut self, property_name: &str) -> Result<JsonValue, Error>
fn remove(&mut self, property_name: &str) -> Result<JsonValue, Error>
assumes the Json Value is a map and tries to remove the given property
Sourcefn remove_into<K: DeserializeOwned>(
&mut self,
property_name: &str,
) -> Result<K, Error>
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
Sourcefn insert(
&mut self,
property_name: String,
value: JsonValue,
) -> Result<(), Error>
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
Sourcefn push(&mut self, value: JsonValue) -> Result<(), Error>
fn push(&mut self, value: JsonValue) -> Result<(), Error>
assumes the Json Value is an array and tries to add value to the array
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>
Sourcefn get_value_mut(&mut self, string_path: &str) -> Result<&mut JsonValue, Error>
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
Sourcefn get_value(&self, string_path: &str) -> Result<&JsonValue, Error>
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
Sourcefn get_value_by_path(&self, path: &[JsonPathStep]) -> Result<&JsonValue, Error>
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
Sourcefn get_value_by_path_mut(
&mut self,
path: &[JsonPathStep],
) -> Result<&mut JsonValue, Error>
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
Sourcefn remove_u32(&mut self, property_name: &str) -> Result<u32, Error>
fn remove_u32(&mut self, property_name: &str) -> Result<u32, Error>
assumes that the JsonValue is a Map and tries to remove the u32
fn add_protocol_version( &mut self, property_name: &str, protocol_version: u32, ) -> Result<(), ProtocolError>
Sourcefn insert_with_path(
&mut self,
path: &str,
value: JsonValue,
) -> Result<(), Error>
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
Sourcefn remove_value_at_path_into<K: DeserializeOwned>(
&mut self,
property_name: &str,
) -> Result<K, Error>
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
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.