Trait AsyncCreateWithAndValidate

Source
pub trait AsyncCreateWithAndValidate<X>:
    Sized
    + AsyncTryFrom<X>
    + ValidateIntegrity<Error = <Self as AsyncTryFrom<X>>::Error>
where for<'async_trait> X: Send + Sync + 'async_trait,
{ // Provided method fn new_and_validate<'life0, 'async_trait>( input: &'life0 X, ) -> Pin<Box<dyn Future<Output = Result<Self, <Self as AsyncTryFrom<X>>::Error>> + Send + 'async_trait>> where Self: Send + 'async_trait, 'life0: 'async_trait { ... } }
Expand description

Trait that combines async creation with integrity validation

Provided Methods§

Source

fn new_and_validate<'life0, 'async_trait>( input: &'life0 X, ) -> Pin<Box<dyn Future<Output = Result<Self, <Self as AsyncTryFrom<X>>::Error>> + Send + 'async_trait>>
where Self: Send + 'async_trait, 'life0: 'async_trait,

Examples found in repository?
examples/basic_usage.rs (line 37)
35    pub async fn run_example() -> Result<(), Box<dyn std::error::Error>> {
36        let input = "Some input".to_string();
37        let _instance = MyType::new_and_validate(&input).await?;
38        println!("Successfully created and validated MyType instance.");
39        Ok(())
40    }

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<X, T> AsyncCreateWithAndValidate<X> for T
where for<'async_trait> X: Send + Sync + 'async_trait, T: AsyncTryFrom<X> + ValidateIntegrity<Error = <T as AsyncTryFrom<X>>::Error>,