pub struct CoreBuilder { /* private fields */ }Expand description
Builder for Core.
The builder separates operation descriptors from handlers so modules can
mount descriptors first and callers can register concrete behavior later.
CoreBuilder::build validates that both sides are present before it
returns a runnable runtime.
Implementations§
Source§impl CoreBuilder
impl CoreBuilder
Sourcepub fn mount(&mut self, module: Module) -> Result<&mut Self, BuildError>
pub fn mount(&mut self, module: Module) -> Result<&mut Self, BuildError>
Mount a data-oriented module descriptor into this builder.
§Errors
Returns a build error when the module is invalid or when any descriptor duplicates an operation already registered in this builder.
Sourcepub fn register_operation(
&mut self,
descriptor: OperationDescriptor,
) -> Result<&mut Self, BuildError>
pub fn register_operation( &mut self, descriptor: OperationDescriptor, ) -> Result<&mut Self, BuildError>
Register an operation descriptor without a handler.
§Errors
Returns BuildError::DuplicateOperation when the descriptor name is
already present.
Sourcepub fn register_handler<H>(
&mut self,
name: impl Into<String>,
handler: H,
) -> Result<&mut Self, BuildError>where
H: Handler + 'static,
pub fn register_handler<H>(
&mut self,
name: impl Into<String>,
handler: H,
) -> Result<&mut Self, BuildError>where
H: Handler + 'static,
Register a handler for an operation name.
§Errors
Returns BuildError::DuplicateHandler when a handler for name is
already present.
Sourcepub fn register<H>(
&mut self,
descriptor: OperationDescriptor,
handler: H,
) -> Result<&mut Self, BuildError>where
H: Handler + 'static,
pub fn register<H>(
&mut self,
descriptor: OperationDescriptor,
handler: H,
) -> Result<&mut Self, BuildError>where
H: Handler + 'static,
Register a descriptor and handler together.
§Errors
Returns a duplicate descriptor or duplicate handler error if either side is already present.
Sourcepub fn register_item(
&mut self,
item: OperationRegisterItem,
) -> Result<&mut Self, BuildError>
pub fn register_item( &mut self, item: OperationRegisterItem, ) -> Result<&mut Self, BuildError>
Register a macro-generated operation item.
§Errors
Returns the same duplicate or validation errors as Self::register.
Sourcepub fn register_boxed(
&mut self,
descriptor: OperationDescriptor,
handler: Box<dyn Handler + 'static>,
) -> Result<&mut Self, BuildError>
pub fn register_boxed( &mut self, descriptor: OperationDescriptor, handler: Box<dyn Handler + 'static>, ) -> Result<&mut Self, BuildError>
Register a descriptor and an already-boxed handler together.
A composition layer above this builder (such as a module host) holds its
handlers as trait objects; this admits them without re-boxing. Validation
and duplicate detection match Self::register.
§Errors
Returns a duplicate descriptor or duplicate handler error if either side is already present, or an invalid-operation error if the descriptor fails validation.
Sourcepub fn admission_guard<G>(&mut self, guard: G) -> &mut Selfwhere
G: AdmissionGuard + 'static,
pub fn admission_guard<G>(&mut self, guard: G) -> &mut Selfwhere
G: AdmissionGuard + 'static,
Configure the optional pre-handler admission guard.
The guard runs before every handler dispatch and may deny the call (the
handler never runs, and the runtime records a Denied receipt). At most
one guard is held; compose multiple policies inside a single guard.
Sourcepub fn clear_admission_guard(&mut self) -> &mut Self
pub fn clear_admission_guard(&mut self) -> &mut Self
Clear any configured admission guard.
Sourcepub fn receipt_sink<S>(&mut self, sink: S) -> &mut Selfwhere
S: ReceiptSink + 'static,
pub fn receipt_sink<S>(&mut self, sink: S) -> &mut Selfwhere
S: ReceiptSink + 'static,
Configure the optional receipt sink made available to invocation contexts.
Sourcepub fn receipt_sink_boxed(
&mut self,
sink: Box<dyn ReceiptSink + 'static>,
) -> &mut Self
pub fn receipt_sink_boxed( &mut self, sink: Box<dyn ReceiptSink + 'static>, ) -> &mut Self
Configure the optional receipt sink from an already-boxed trait object.
Equivalent to Self::receipt_sink for a composition layer that holds
its sink as a trait object.
Sourcepub fn without_receipts(&mut self) -> &mut Self
pub fn without_receipts(&mut self) -> &mut Self
Explicitly build a core that records no receipts.
Self::build fails closed with BuildError::MissingReceiptSink when
no receipt sink is configured, because a sinkless core silently drops
every runtime receipt. Call this to state on purpose that this core
persists no receipts. A receipt sink configured with
Self::receipt_sink takes precedence and still persists receipts.
Sourcepub fn status_sink<S>(&mut self, sink: S) -> &mut Self
pub fn status_sink<S>(&mut self, sink: S) -> &mut Self
Configure the optional operation-status sink used during checkout.
Sourcepub fn status_sink_boxed(
&mut self,
sink: Arc<dyn OperationStatusSink + Send + Sync>,
) -> &mut Self
pub fn status_sink_boxed( &mut self, sink: Arc<dyn OperationStatusSink + Send + Sync>, ) -> &mut Self
Configure the operation-status sink from an already-boxed trait object.
Sourcepub fn clear_status_sink(&mut self) -> &mut Self
pub fn clear_status_sink(&mut self) -> &mut Self
Clear any configured operation-status sink.
Sourcepub fn receipt_hash_policy(&mut self, policy: ReceiptHashPolicy) -> &mut Self
pub fn receipt_hash_policy(&mut self, policy: ReceiptHashPolicy) -> &mut Self
Configure runtime receipt hash population.
Sourcepub fn grant_capability(&mut self, capability: impl Into<String>) -> &mut Self
pub fn grant_capability(&mut self, capability: impl Into<String>) -> &mut Self
Grant one runtime capability token to the built Core.
At checkout the runtime fails closed when a dispatched operation declares
a required capability token it was not granted. Tokens are declared with
OperationEffectRow::requires_capability or the #[operation] macro’s
requires_capabilities. Effect-axis tokens auto-declared by the effect
builders (event read/append, projection query, receipt emit, host
control) are ambient — they are mediated by the observed-effect subset
check and never need an explicit grant. A Core granted nothing therefore
runs only operations that declare no extra capability tokens.
Sourcepub fn grant_capabilities<I, S>(&mut self, capabilities: I) -> &mut Self
pub fn grant_capabilities<I, S>(&mut self, capabilities: I) -> &mut Self
Grant several runtime capability tokens to the built Core.
Convenience over repeated Self::grant_capability calls; see it for
the gate semantics.
Sourcepub fn effect_backend<B>(&mut self, backend: B) -> &mut Selfwhere
B: EffectBackend + 'static,
pub fn effect_backend<B>(&mut self, backend: B) -> &mut Selfwhere
B: EffectBackend + 'static,
Configure the runtime-owned effect backend.
Operations append events only through Ctx, which performs the append
through this backend. Without a backend bound, an append_event call from
a handler fails closed rather than reaching a store the runtime did not
mediate.
Sourcepub fn effect_backend_boxed(
&mut self,
backend: Box<dyn EffectBackend + 'static>,
) -> &mut Self
pub fn effect_backend_boxed( &mut self, backend: Box<dyn EffectBackend + 'static>, ) -> &mut Self
Configure the effect backend from an already-boxed trait object.
Equivalent to Self::effect_backend for a composition layer that holds
its backend as a trait object.
Sourcepub fn build(self) -> Result<Core, BuildError>
pub fn build(self) -> Result<Core, BuildError>
Build a runnable Core.
§Errors
Returns a missing-descriptor or missing-handler error when the mounted
operation table and handler table do not line up by name, or
BuildError::MissingReceiptSink when no receipt sink is configured and
the caller did not opt out with Self::without_receipts (a sinkless
core silently drops every runtime receipt, so the build fails closed).
Trait Implementations§
Source§impl Default for CoreBuilder
impl Default for CoreBuilder
Source§fn default() -> CoreBuilder
fn default() -> CoreBuilder
Auto Trait Implementations§
impl !RefUnwindSafe for CoreBuilder
impl !Send for CoreBuilder
impl !Sync for CoreBuilder
impl !UnwindSafe for CoreBuilder
impl Freeze for CoreBuilder
impl Unpin for CoreBuilder
impl UnsafeUnpin for CoreBuilder
Blanket Implementations§
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> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more