Skip to main content

PersistentFactory

Trait PersistentFactory 

Source
pub trait PersistentFactory<M>: Factory<M>
where M: Send,
{ // Required method fn save<'life0, 'async_trait>( c: &'life0 Container, model: M, ) -> Pin<Box<dyn Future<Output = Result<M, Error>> + Send + 'async_trait>> where 'life0: 'async_trait; // Provided methods fn create<'life0, 'async_trait>( c: &'life0 Container, ) -> Pin<Box<dyn Future<Output = Result<M, Error>> + Send + 'async_trait>> where Self: Send + 'async_trait, 'life0: 'async_trait { ... } fn create_many<'life0, 'async_trait>( c: &'life0 Container, count: usize, ) -> Pin<Box<dyn Future<Output = Result<Vec<M>, Error>> + Send + 'async_trait>> where Self: Send + 'async_trait, 'life0: 'async_trait { ... } }
Expand description

Helper for factories that want to persist instances.

Implementing this manually per model lets the factory call into the model’s insert SQL.

Required Methods§

Source

fn save<'life0, 'async_trait>( c: &'life0 Container, model: M, ) -> Pin<Box<dyn Future<Output = Result<M, Error>> + Send + 'async_trait>>
where 'life0: 'async_trait,

Provided Methods§

Source

fn create<'life0, 'async_trait>( c: &'life0 Container, ) -> Pin<Box<dyn Future<Output = Result<M, Error>> + Send + 'async_trait>>
where Self: Send + 'async_trait, 'life0: 'async_trait,

Generate + persist a single instance.

Source

fn create_many<'life0, 'async_trait>( c: &'life0 Container, count: usize, ) -> Pin<Box<dyn Future<Output = Result<Vec<M>, Error>> + Send + 'async_trait>>
where Self: Send + 'async_trait, 'life0: 'async_trait,

Generate + persist count instances. Returns them in insertion order.

Dyn Compatibility§

This trait is not dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety".

Implementors§