Skip to content

Commit e4ef19c

Browse files
committed
editoast: change Model traits CreateBatch,WithKey to use editoast_models::Error
Signed-off-by: Leo Valais <[email protected]>
1 parent 240211d commit e4ef19c

File tree

4 files changed

+17
-8
lines changed

4 files changed

+17
-8
lines changed

editoast/editoast_derive/src/model/codegen/create_batch_impl.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,7 @@ impl ToTokens for CreateBatchImpl {
5858
>(
5959
conn: &mut editoast_models::DbConnection,
6060
values: I,
61-
) -> crate::error::Result<C> {
61+
) -> std::result::Result<C, editoast_models::model::Error> {
6262
use crate::models::Model;
6363
use #table_mod::dsl;
6464
use std::ops::DerefMut;

editoast/editoast_derive/src/model/codegen/create_batch_with_key_impl.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,7 @@ impl ToTokens for CreateBatchWithKeyImpl {
6969
>(
7070
conn: &mut editoast_models::DbConnection,
7171
values: I,
72-
) -> crate::error::Result<C> {
72+
) -> std::result::Result<C, editoast_models::model::Error> {
7373
use crate::models::Identifiable;
7474
use crate::models::Model;
7575
use std::ops::DerefMut;

editoast/editoast_derive/src/snapshots/editoast_derive__model__tests__construction.snap

+12-3
Original file line numberDiff line numberDiff line change
@@ -613,7 +613,10 @@ impl crate::models::CreateBatch<DocumentChangeset> for Document {
613613
async fn create_batch<
614614
I: std::iter::IntoIterator<Item = DocumentChangeset> + Send + 'async_trait,
615615
C: Default + std::iter::Extend<Self> + Send + std::fmt::Debug,
616-
>(conn: &mut editoast_models::DbConnection, values: I) -> crate::error::Result<C> {
616+
>(
617+
conn: &mut editoast_models::DbConnection,
618+
values: I,
619+
) -> std::result::Result<C, editoast_models::model::Error> {
617620
use crate::models::Model;
618621
use editoast_models::tables::osrd_infra_document::dsl;
619622
use std::ops::DerefMut;
@@ -654,7 +657,10 @@ impl crate::models::CreateBatchWithKey<DocumentChangeset, (String)> for Document
654657
async fn create_batch_with_key<
655658
I: std::iter::IntoIterator<Item = DocumentChangeset> + Send + 'async_trait,
656659
C: Default + std::iter::Extend<((String), Self)> + Send + std::fmt::Debug,
657-
>(conn: &mut editoast_models::DbConnection, values: I) -> crate::error::Result<C> {
660+
>(
661+
conn: &mut editoast_models::DbConnection,
662+
values: I,
663+
) -> std::result::Result<C, editoast_models::model::Error> {
658664
use crate::models::Identifiable;
659665
use crate::models::Model;
660666
use std::ops::DerefMut;
@@ -698,7 +704,10 @@ impl crate::models::CreateBatchWithKey<DocumentChangeset, (i64)> for Document {
698704
async fn create_batch_with_key<
699705
I: std::iter::IntoIterator<Item = DocumentChangeset> + Send + 'async_trait,
700706
C: Default + std::iter::Extend<((i64), Self)> + Send + std::fmt::Debug,
701-
>(conn: &mut editoast_models::DbConnection, values: I) -> crate::error::Result<C> {
707+
>(
708+
conn: &mut editoast_models::DbConnection,
709+
values: I,
710+
) -> std::result::Result<C, editoast_models::model::Error> {
702711
use crate::models::Identifiable;
703712
use crate::models::Model;
704713
use std::ops::DerefMut;

editoast/src/models/prelude/create.rs

+3-3
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
11
use std::fmt::Debug;
2+
use std::result::Result;
23

34
use editoast_models::model;
45
use editoast_models::DbConnection;
56

67
use crate::error::EditoastError;
7-
use crate::error::Result;
88

99
use super::Model;
1010

@@ -57,7 +57,7 @@ where
5757
>(
5858
conn: &mut DbConnection,
5959
values: I,
60-
) -> Result<C>;
60+
) -> Result<C, model::Error>;
6161
}
6262

6363
/// Describes how a [Model](super::Model) can be created in the database given a batch of its changesets
@@ -81,5 +81,5 @@ where
8181
>(
8282
conn: &mut DbConnection,
8383
values: I,
84-
) -> Result<C>;
84+
) -> Result<C, model::Error>;
8585
}

0 commit comments

Comments
 (0)