Skip to main content

Module id_source

Module id_source 

Source
Expand description

Where a repo’s entities get their id from, and the one public route into an EntityEvents container.

A repo resolves the id of every entity it creates according to its IdSource: FromRepo (the default, the repo generates it) or FromCaller (the caller puts it in the New* value). The IntoEvents implementation of a New* type receives an EntityEventsBuilder whose second parameter is that source, so EntityEventsBuilder::id exists only when the repo resolved one, and a FromRepo New* has no API through which a caller-chosen id can reach the insert.

Structs§

EntityEventsBuilder
The id source applied, no events yet. Handed to IntoEvents::into_events by the generated repo code and consumed by initial_events, the only public way to build an EntityEvents container.
FromCaller
The caller puts the id (a deterministic one) in the New* value, which hands it to EntityEventsBuilder::initial_events. A caller’s id is a uniqueness claim, so the primary key stays among the repo’s constraint violations.
FromRepo
The repo resolved the id before into_events runs; the New* type has no id field and reads it with EntityEventsBuilder::id.

Enums§

Ensured
What create_or_find_in_op did.

Traits§

IdSource
Where the id of a newly created entity comes from. Sealed: FromRepo and FromCaller are the only sources.