pub trait SerializeHelper<T> {
// Required methods
fn get_val_unsafe(&self, attr: &str, fun: fn(&Values) -> Option<T>) -> T;
fn get_val_opt(
&self,
attr: &str,
fun: fn(&Values) -> Option<T>,
) -> Option<T>;
fn get_val_res(
&self,
attr: &str,
fun: fn(&Values) -> Option<T>,
) -> Result<T, ParseError>;
fn rm_val(
&mut self,
attr: &str,
fun: fn(Values) -> Option<T>,
) -> Result<T, ParseError>;
fn map_val(
&mut self,
attr: &str,
fun: fn(Values) -> Result<T, ParseError>,
) -> Result<T, ParseError>;
fn map_ref_val(
&mut self,
attr: &str,
fun: fn(&Values) -> Result<T, ParseError>,
) -> Result<T, ParseError>;
fn map_val_and_err<E: Error>(
&mut self,
attr: &str,
fun: fn(Values) -> Result<T, E>,
) -> Result<T, ParseError>;
fn map_opt_val(
&mut self,
attr: &str,
fun: fn(Values) -> Option<T>,
) -> Result<Option<T>, ParseError>;
}Expand description
Helper Trait for Serializing JSON
Required Methods§
Sourcefn get_val_unsafe(&self, attr: &str, fun: fn(&Values) -> Option<T>) -> T
fn get_val_unsafe(&self, attr: &str, fun: fn(&Values) -> Option<T>) -> T
directly get T without any further checks
Warning: this operation calls the .unwrap() method
Sourcefn get_val_opt(&self, attr: &str, fun: fn(&Values) -> Option<T>) -> Option<T>
fn get_val_opt(&self, attr: &str, fun: fn(&Values) -> Option<T>) -> Option<T>
get an Option<T> without the Error message why the operation maybe failed
Sourcefn get_val_res(
&self,
attr: &str,
fun: fn(&Values) -> Option<T>,
) -> Result<T, ParseError>
fn get_val_res( &self, attr: &str, fun: fn(&Values) -> Option<T>, ) -> Result<T, ParseError>
get a Result of T or ParseError containing Info why the operation failed.
In this case the function only takes a referenced Values object and returns an Option<T>
Sourcefn rm_val(
&mut self,
attr: &str,
fun: fn(Values) -> Option<T>,
) -> Result<T, ParseError>
fn rm_val( &mut self, attr: &str, fun: fn(Values) -> Option<T>, ) -> Result<T, ParseError>
get a Result of T or ParseError containing Info why the operation failed.
In this case the function only takes a Values object and returns an Option<T>
Sourcefn map_val(
&mut self,
attr: &str,
fun: fn(Values) -> Result<T, ParseError>,
) -> Result<T, ParseError>
fn map_val( &mut self, attr: &str, fun: fn(Values) -> Result<T, ParseError>, ) -> Result<T, ParseError>
get a Result of T or ParseError containing Info why the operation failed.
In this case the function only takes a Values object and returns an Result<T,ParseError>
Sourcefn map_ref_val(
&mut self,
attr: &str,
fun: fn(&Values) -> Result<T, ParseError>,
) -> Result<T, ParseError>
fn map_ref_val( &mut self, attr: &str, fun: fn(&Values) -> Result<T, ParseError>, ) -> Result<T, ParseError>
get a Result of T or ParseError containing Info why the operation failed.
In this case the function only takes a referenced Values object and returns an Result<T,ParseError>
Sourcefn map_val_and_err<E: Error>(
&mut self,
attr: &str,
fun: fn(Values) -> Result<T, E>,
) -> Result<T, ParseError>
fn map_val_and_err<E: Error>( &mut self, attr: &str, fun: fn(Values) -> Result<T, E>, ) -> Result<T, ParseError>
get a Result of T or ParseError containing Info why the operation failed.
In this case the function only takes a referenced Values object and returns an Result<T,E>
Sourcefn map_opt_val(
&mut self,
attr: &str,
fun: fn(Values) -> Option<T>,
) -> Result<Option<T>, ParseError>
fn map_opt_val( &mut self, attr: &str, fun: fn(Values) -> Option<T>, ) -> Result<Option<T>, ParseError>
get a Result of Option<T> or ParseError containing Info why the operation failed.
In this case the function only takes a referenced Values object and returns an Result<T,ParseError>
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.