pub trait ToStructMappingFieldwhere
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§
Sourcefn sm_mutator(key: &str, value: &str) -> Result<Self, MutatorError>
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.