Trait ToStructMappingField

Source
pub trait ToStructMappingField
where Self: Sized,
{ // Required method fn sm_mutator(key: &str, value: &str) -> Result<Self, MutatorError>; }
Expand description

The public trait ToStructMappingField allows to implement a new type serialization

§Example

impl ToStructMappingField for bool {
#[inline]
fn sm_mutator(key: &str, value: &str) -> Result<Self, MutatorError> {
    value
        .parse::<bool>()
        .map_err(|err| MutatorError::InvalidValue {
            key: key.to_string(),
            error: err.to_string(),
        })
}

Required Methods§

Source

fn sm_mutator(key: &str, value: &str) -> Result<Self, MutatorError>

Method to convert a &str into a Self value for serialization

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 ToStructMappingField for bool

Source§

fn sm_mutator(key: &str, value: &str) -> Result<Self, MutatorError>

Source§

impl ToStructMappingField for char

Source§

fn sm_mutator(key: &str, value: &str) -> Result<Self, MutatorError>

Source§

impl ToStructMappingField for f32

Source§

fn sm_mutator(key: &str, value: &str) -> Result<Self, MutatorError>

Source§

impl ToStructMappingField for f64

Source§

fn sm_mutator(key: &str, value: &str) -> Result<Self, MutatorError>

Source§

impl ToStructMappingField for i8

Source§

fn sm_mutator(key: &str, value: &str) -> Result<Self, MutatorError>

Source§

impl ToStructMappingField for i16

Source§

fn sm_mutator(key: &str, value: &str) -> Result<Self, MutatorError>

Source§

impl ToStructMappingField for i32

Source§

fn sm_mutator(key: &str, value: &str) -> Result<Self, MutatorError>

Source§

impl ToStructMappingField for i64

Source§

fn sm_mutator(key: &str, value: &str) -> Result<Self, MutatorError>

Source§

impl ToStructMappingField for isize

Source§

fn sm_mutator(key: &str, value: &str) -> Result<Self, MutatorError>

Source§

impl ToStructMappingField for u8

Source§

fn sm_mutator(key: &str, value: &str) -> Result<Self, MutatorError>

Source§

impl ToStructMappingField for u16

Source§

fn sm_mutator(key: &str, value: &str) -> Result<Self, MutatorError>

Source§

impl ToStructMappingField for u32

Source§

fn sm_mutator(key: &str, value: &str) -> Result<Self, MutatorError>

Source§

impl ToStructMappingField for u64

Source§

fn sm_mutator(key: &str, value: &str) -> Result<Self, MutatorError>

Source§

impl ToStructMappingField for usize

Source§

fn sm_mutator(key: &str, value: &str) -> Result<Self, MutatorError>

Implementors§