Trait FromTomlSlice

Source
pub trait FromTomlSlice<'de>
where Self: Sized,
{ // Required method fn from_toml_slice(slice: &'de [u8]) -> Result<Self, Error<Error>>; }

Required Methods§

Source

fn from_toml_slice(slice: &'de [u8]) -> Result<Self, Error<Error>>

Convert from toml slice.

use serde::Deserialize;
use serde_valid::Validate;
use serde_valid::toml::FromTomlSlice;

#[derive(Debug, Validate, Deserialize)]
struct TestStruct {
    #[validate(min_length = 1)]
    val: String,
}

let s = TestStruct::from_toml_slice(br#"val= "abcde""#);

s.unwrap();

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.

Implementors§

Source§

impl<'de, T> FromTomlSlice<'de> for T
where T: Deserialize<'de> + Validate,