Skip to content

Commit 92b2ea3

Browse files
committed
refactor(core::factory): use generics
1 parent 98f2b93 commit 92b2ea3

File tree

1 file changed

+3
-9
lines changed

1 file changed

+3
-9
lines changed

src/core/factory.rs

Lines changed: 3 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -3,13 +3,7 @@ use async_trait::async_trait;
33
use super::db;
44

55
#[async_trait]
6-
pub trait ModelFactory {
7-
type Request;
8-
type Model;
9-
10-
fn factory_build() -> Self::Request;
11-
async fn factory_create(
12-
obj: Option<Self::Request>,
13-
pool: db::PgPool,
14-
) -> Result<Self::Model, db::Error>;
6+
pub trait ModelFactory<Model, NewModel> {
7+
fn build() -> NewModel;
8+
async fn create(obj: Option<NewModel>, pool: db::PgPool) -> Result<Model, db::Error>;
159
}

0 commit comments

Comments
 (0)