SerializeHelper

Trait SerializeHelper 

Source
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§

Source

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

Source

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

Source

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>

Source

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>

Source

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>

Source

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>

Source

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>

Source

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.

Implementations on Foreign Types§

Source§

impl<T> SerializeHelper<T> for HashMap<String, Values>

Source§

fn get_val_unsafe(&self, attr: &str, fun: fn(&Values) -> Option<T>) -> T

Source§

fn get_val_opt(&self, attr: &str, fun: fn(&Values) -> Option<T>) -> Option<T>

Source§

fn get_val_res( &self, attr: &str, fun: fn(&Values) -> Option<T>, ) -> Result<T, ParseError>

Source§

fn rm_val( &mut self, attr: &str, fun: fn(Values) -> Option<T>, ) -> Result<T, ParseError>

Source§

fn map_val( &mut self, attr: &str, fun: fn(Values) -> Result<T, ParseError>, ) -> Result<T, ParseError>

Source§

fn map_ref_val( &mut self, attr: &str, fun: fn(&Values) -> Result<T, ParseError>, ) -> Result<T, ParseError>

Source§

fn map_val_and_err<E: Error>( &mut self, attr: &str, fun: fn(Values) -> Result<T, E>, ) -> Result<T, ParseError>

Source§

fn map_opt_val( &mut self, attr: &str, fun: fn(Values) -> Option<T>, ) -> Result<Option<T>, ParseError>

Implementors§