#[derive(Entity)]
{
// Attributes available to this derive:
#[entity]
}
Expand description
English:
Implements ddd_toolkit_core::Entity, a borrowed inherent id()
accessor, and PartialEq, Eq, and Hash using only the identifier field.
Requires a named-field struct with exactly one #[entity(id)] field. Other
fields do not participate in comparison or hashing; identifier types must
implement the corresponding traits. No constructor or identifier validation
is generated. Non-struct inputs, misplaced flags, missing or multiple identifier
fields, unknown options, and missing core dependencies cause compile errors.
日本語:
ddd_toolkit_core::Entity と識別子を借用する固有の id()、
識別子フィールドだけを使う PartialEq、Eq、Hash を実装します。
名前付き構造体に #[entity(id)] フィールドがちょうど一つ必要です。
他のフィールドは比較やハッシュに使いません。識別子型は対応するトレイトを
実装する必要があります。コンストラクターや識別子の検証は生成しません。
構造体以外、フラグの誤配置、識別子の欠落・複数指定、未知のオプション、
コア依存の欠落はコンパイルエラーになります。
§Example / 使用例
use ddd_toolkit_macro::Entity;
#[derive(Entity)]
struct Order {
#[entity(id)]
id: u64,
total: u32,
}
let first = Order { id: 1, total: 10 };
let updated = Order { id: 1, total: 20 };
assert!(first == updated);
assert_eq!(updated.id(), &1);