ddd_toolkit_core/domain_factory.rs
1/// **English:**<br>
2/// Constructs a domain product from owned input, reporting a typed construction error.
3/// Validation, identifier allocation, and side effects are chosen by the implementation;
4/// this trait does not require the product to be an aggregate or provide persistence.
5/// A shared receiver does not require `Send`, `Sync`, or side-effect-free construction.
6///
7/// **日本語:**<br>
8/// 所有する入力からドメインの生成物を構築し、型付きの構築エラーを返します。
9/// 検証、識別子の割り当て、副作用は実装が定めます。生成物を集約に制限せず、永続化も提供しません。
10/// 共有参照のレシーバーは、`Send`、`Sync`、副作用のない構築を要求するものではありません。
11pub trait DomainFactory<Input> {
12 /// **English:**<br>
13 /// Value returned after successful construction; no domain trait bound is imposed.
14 ///
15 /// **日本語:**<br>
16 /// 構築成功時に返す値です。ドメイントレイトの境界は課しません。
17 type Product;
18
19 /// **English:**<br>
20 /// Implementation-defined reason that construction could not return a product.
21 ///
22 /// **日本語:**<br>
23 /// 生成物を返せなかった理由を表す実装定義のエラーです。
24 type Error;
25
26 /// **English:**<br>
27 /// Consumes `input` and returns a product or a construction error.
28 /// The implementation specifies validation rules, failure side effects, and any panics.
29 ///
30 /// **日本語:**<br>
31 /// `input` を消費し、生成物または構築エラーを返します。
32 /// 検証規則、失敗時の副作用、パニックの条件は実装が定めます。
33 fn create(&self, input: Input) -> Result<Self::Product, Self::Error>;
34}