pub struct RepositoryBuilder<S, C, A, Snap = NoSnapshot, M = ()> { /* private fields */ }Expand description
Builder for creating an EventStore facade
from a Store.
Obtained via Store::repository(), which always starts the builder with
NeedsCodec. Set a codec with .codec() or,
under the json feature, .json().
Upcasting is not configured here — the resulting facade ships with
the no-upcaster Repository::load /
save path. For schema evolution, use the
facade’s inherent load_with /
save_with methods after build().
§Example
let store = Store::new(backend);
// Built-in JSON codec (requires the `json` feature):
let repo = store.repository::<Order>().json().build();
// Custom codec:
let repo = store.repository::<Order>().codec(MyCodec).build();
// With metadata provider (e.g. HLC stamp, signature bytes):
let repo = store.repository::<Order>().codec(MyCodec).metadata(|v, e, p| Some(...)).build();
// With upcasting (drop to the facade after build):
let repo = store.repository::<Order>().codec(MyCodec).build();
let root = repo.load_with(id, OrderTransforms::upcast).await?;Implementations§
Source§impl<S, C, A, Snap, M> RepositoryBuilder<S, C, A, Snap, M>
impl<S, C, A, Snap, M> RepositoryBuilder<S, C, A, Snap, M>
Sourcepub fn codec<NewC>(self, codec: NewC) -> RepositoryBuilder<S, NewC, A, Snap, M>
pub fn codec<NewC>(self, codec: NewC) -> RepositoryBuilder<S, NewC, A, Snap, M>
Replace the codec.
Returns a new builder with the updated codec type, preserving the store, the bound aggregate, any snapshot configuration, and any configured metadata provider.
Sourcepub fn metadata<NewM>(
self,
provider: NewM,
) -> RepositoryBuilder<S, C, A, Snap, NewM>
pub fn metadata<NewM>( self, provider: NewM, ) -> RepositoryBuilder<S, C, A, Snap, NewM>
Set the metadata provider for this facade.
The provider is called once per event on the write path (post-encode)
and can return Some(Metadata) to attach to the envelope or None to
leave metadata absent. It is infallible; cap errors are handled by the
provider at Metadata construction.
Order-independent: may be called before or after .codec(),
.snapshot_store(), etc.
Source§impl<S, C, A, Snap, M> RepositoryBuilder<S, C, A, Snap, M>
impl<S, C, A, Snap, M> RepositoryBuilder<S, C, A, Snap, M>
Sourcepub fn json(self) -> RepositoryBuilder<S, JsonCodec, A, Snap, M>
pub fn json(self) -> RepositoryBuilder<S, JsonCodec, A, Snap, M>
Use the built-in JsonCodec as this facade’s codec.
Convenience for .codec(JsonCodec::default()). This is additive API:
enabling the json feature only adds this method — it never changes
Store::repository()’s return type, which is always
NeedsCodec regardless of features (issue #211).
Source§impl<S, C, A, M> RepositoryBuilder<S, C, A, NoSnapshot, M>
impl<S, C, A, M> RepositoryBuilder<S, C, A, NoSnapshot, M>
Sourcepub fn build(self) -> EventStore<S, C, A, M>
pub fn build(self) -> EventStore<S, C, A, M>
Build an EventStore for aggregate A.
One terminal for any codec: the owning-vs-borrowing distinction is
inferred from the codec’s Decode::Output
GAT (E or &E, unified via Borrow<E>), not restated at the call
site. Requires a configured codec (C: Send + Sync + 'static, which
excludes NeedsCodec).
Source§impl<S, C, A, M> RepositoryBuilder<S, C, A, NoSnapshot, M>
impl<S, C, A, M> RepositoryBuilder<S, C, A, NoSnapshot, M>
Sourcepub fn snapshot_store_json<SS>(
self,
snapshot_store: SS,
) -> RepositoryBuilder<S, C, A, WithSnapshot<CodecSnapshotStore<SS, JsonCodec>, EveryNEvents>, M>
pub fn snapshot_store_json<SS>( self, snapshot_store: SS, ) -> RepositoryBuilder<S, C, A, WithSnapshot<CodecSnapshotStore<SS, JsonCodec>, EveryNEvents>, M>
Configure a snapshot store from a byte-level store, wrapping it in the
built-in JsonCodec.
Accepts a byte-level SnapshotStore<Vec<u8>, Version>
and wraps it in CodecSnapshotStore with
JsonCodec. This is the snapshot-json convenience
for .snapshot_store() (which takes
an already-typed store); enabling snapshot-json adds this method
without altering snapshot_store()’s signature — feature-additivity
(issue #211).
Pre-fills:
- Trigger:
EveryNEvents(100) - Schema version: 1
- Snapshot on read: false
Override any default with .snapshot_trigger(), etc.
§Panics
Cannot panic — the internal expect is on a compile-time constant.
Source§impl<S, C, A, M> RepositoryBuilder<S, C, A, NoSnapshot, M>
impl<S, C, A, M> RepositoryBuilder<S, C, A, NoSnapshot, M>
Sourcepub fn snapshot_store<SS>(
self,
snapshot_store: SS,
) -> RepositoryBuilder<S, C, A, WithSnapshot<SS, EveryNEvents>, M>
pub fn snapshot_store<SS>( self, snapshot_store: SS, ) -> RepositoryBuilder<S, C, A, WithSnapshot<SS, EveryNEvents>, M>
Configure a snapshot store.
Accepts a pre-composed typed SnapshotStore<S, Version>.
If your store is byte-level, compose it with
CodecSnapshotStore before passing it here —
or, under the snapshot-json feature, use the
.snapshot_store_json()
convenience which wraps a byte-level store in JsonCodec.
This method’s signature is the same in every feature configuration
(issue #211): snapshot-json adds snapshot_store_json() rather than
changing what snapshot_store() accepts.
Pre-fills:
- Trigger:
EveryNEvents(100) - Schema version: 1
- Snapshot on read: false
Override any default with .snapshot_trigger(), etc.
§Panics
Cannot panic — the internal expect is on a compile-time constant.
Source§impl<S, C, A, SS, T, M> RepositoryBuilder<S, C, A, WithSnapshot<SS, T>, M>
impl<S, C, A, SS, T, M> RepositoryBuilder<S, C, A, WithSnapshot<SS, T>, M>
Sourcepub fn snapshot_trigger<NewT: PersistTrigger>(
self,
trigger: NewT,
) -> RepositoryBuilder<S, C, A, WithSnapshot<SS, NewT>, M>
pub fn snapshot_trigger<NewT: PersistTrigger>( self, trigger: NewT, ) -> RepositoryBuilder<S, C, A, WithSnapshot<SS, NewT>, M>
Replace the snapshot trigger.
Sourcepub const fn snapshot_schema_version(self, version: NonZeroU32) -> Self
pub const fn snapshot_schema_version(self, version: NonZeroU32) -> Self
Set the schema version for snapshot invalidation.
Sourcepub const fn snapshot_on_read(self, enabled: bool) -> Self
pub const fn snapshot_on_read(self, enabled: bool) -> Self
Enable lazy snapshot creation on read (after full replay).
Source§impl<S, C, A, SS, T, M> RepositoryBuilder<S, C, A, WithSnapshot<SS, T>, M>
impl<S, C, A, SS, T, M> RepositoryBuilder<S, C, A, WithSnapshot<SS, T>, M>
Sourcepub fn build(self) -> Snapshotting<EventStore<S, C, A, M>, SS, T>
pub fn build(self) -> Snapshotting<EventStore<S, C, A, M>, SS, T>
Build a snapshot-aware EventStore for aggregate A using an owning Codec.
Auto Trait Implementations§
impl<S, C, A, Snap, M> Freeze for RepositoryBuilder<S, C, A, Snap, M>
impl<S, C, A, Snap, M> RefUnwindSafe for RepositoryBuilder<S, C, A, Snap, M>
impl<S, C, A, Snap, M> Send for RepositoryBuilder<S, C, A, Snap, M>
impl<S, C, A, Snap, M> Sync for RepositoryBuilder<S, C, A, Snap, M>
impl<S, C, A, Snap, M> Unpin for RepositoryBuilder<S, C, A, Snap, M>
impl<S, C, A, Snap, M> UnsafeUnpin for RepositoryBuilder<S, C, A, Snap, M>
impl<S, C, A, Snap, M> UnwindSafe for RepositoryBuilder<S, C, A, Snap, M>
Blanket Implementations§
Source§impl<T> ArchivePointee for T
impl<T> ArchivePointee for T
Source§type ArchivedMetadata = ()
type ArchivedMetadata = ()
Source§fn pointer_metadata(
_: &<T as ArchivePointee>::ArchivedMetadata,
) -> <T as Pointee>::Metadata
fn pointer_metadata( _: &<T as ArchivePointee>::ArchivedMetadata, ) -> <T as Pointee>::Metadata
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
Source§fn in_current_span(self) -> Instrumented<Self> ⓘ
fn in_current_span(self) -> Instrumented<Self> ⓘ
Source§impl<T> LayoutRaw for T
impl<T> LayoutRaw for T
Source§fn layout_raw(_: <T as Pointee>::Metadata) -> Result<Layout, LayoutError>
fn layout_raw(_: <T as Pointee>::Metadata) -> Result<Layout, LayoutError>
Source§impl<T, N1, N2> Niching<NichedOption<T, N1>> for N2
impl<T, N1, N2> Niching<NichedOption<T, N1>> for N2
Source§unsafe fn is_niched(niched: *const NichedOption<T, N1>) -> bool
unsafe fn is_niched(niched: *const NichedOption<T, N1>) -> bool
Source§fn resolve_niched(out: Place<NichedOption<T, N1>>)
fn resolve_niched(out: Place<NichedOption<T, N1>>)
out indicating that a T is niched.