1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
//! **English:** Re-exports the traits and helpers from `ddd-toolkit-core` 0.4,
//! including [`Entity`], [`ValueObject`], [`AggregateRoot`], [`Repository`],
//! [`AsyncRepository`], event publishing, CQRS, and event-sourcing contracts.
//! Storage adapters and async runtimes are supplied by the application.
//!
//! With the default `derive` feature, the `ValueObject`, `Entity`, `DomainEvent`,
//! and `AggregateRoot` derive macros are also available at this crate's root.
//! Macro 0.4 requires consumers to add `ddd-toolkit-core = "0.4.0"` directly,
//! even when invoking derives through this facade. Trait-only usage does not.
//!
//! The optional `serde` feature enables core's serde support and the serde
//! derives needed by generated deserializers. Serialization is opt-in per value
//! object with `#[value_object(serde)]`; put this flag last when combining options.
//! In macro 0.4.0, single-field tuple enum variants cannot round-trip their own
//! JSON; use named variants instead. [`Secret`] requires no feature and redacts
//! formatting and zeroizes its contents on drop without a feature flag.
//!
//! **日本語:** `ddd-toolkit-core` 0.4 のトレイトとヘルパーを再公開します。
//! [`Entity`]、[`ValueObject`]、[`AggregateRoot`]、[`Repository`]、
//! [`AsyncRepository`]、イベント発行、CQRS、イベントソーシングの契約を含みます。
//! ストレージのアダプターと非同期ランタイムはアプリケーションが提供します。
//!
//! 既定の `derive` feature では `ValueObject`、`Entity`、`DomainEvent`、
//! `AggregateRoot` の derive マクロもルートから利用できます。マクロ 0.4 は
//! ファサード経由でも利用側に `ddd-toolkit-core = "0.4.0"` の直接依存を要求します。
//! トレイトだけを使用する場合、直接依存は不要です。
//!
//! 任意の `serde` feature はコアの serde 対応と生成された逆直列化に必要な serde の
//! derive を有効にします。直列化は型ごとに `#[value_object(serde)]` で指定し、
//! 他のオプションと併用するときはこのフラグを最後に置きます。マクロ 0.4.0 では
//! 1フィールドのタプル型 enum variant は自身の JSON 出力を逆変換できないため、
//! 名前付き variant を使ってください。全 derive に直列化が自動適用されるわけではありません。
//! [`Secret`] は feature 指定なしで使え、書式出力を秘匿化して破棄時に内容をゼロ化します。
//!
//! # Example / 使用例
//!
//! **English:** Validation returns an application-defined error; construction
//! uses `try_new` rather than the removed `TryFrom` implementation.
//!
//! **日本語:** 検証はアプリケーション定義のエラーを返します。廃止された
//! `TryFrom` 実装の代わりに `try_new` で構築します。
//!
//! ```rust
//! # #[cfg(feature = "derive")] {
//! #[derive(ddd_toolkit::ValueObject)]
//! #[value_object(validate = validate_email, error = &'static str)]
//! struct Email(String);
//!
//! fn validate_email(value: &str) -> Result<(), &'static str> {
//! if value.contains('@') { Ok(()) } else { Err("missing @") }
//! }
//!
//! let email = Email::try_new("a@b.com".to_owned()).unwrap();
//! assert_eq!(email.as_inner(), "a@b.com");
//! assert_eq!(Email::try_new("invalid".to_owned()), Err("missing @"));
//! # }
//! let key = ddd_toolkit::Secret::new("sekret".to_owned());
//! assert_eq!(format!("{key:?}"), "[REDACTED]");
//! assert_eq!(key.expose_secret(|value| value.len()), 6);
//! ```
/// **English:** Exposes core 0.4's domain, persistence, and event-workflow API.
///
/// **日本語:** コア 0.4 のドメイン、永続化、イベント処理 API を公開します。
pub use *;
/// **English:** Exposes the four derives; consumers must depend directly on core 0.4.
///
/// **日本語:** 四つの derive を公開します。利用側にコア 0.4 の直接依存が必要です。
pub use *;