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