Skip to main content

CoreBuilder

Struct CoreBuilder 

Source
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

Source

pub fn new() -> Self

Create an empty builder.

Source

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.

Source

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.

Source

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.

Source

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.

Source

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.

Source

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.

Source

pub fn admission_guard<G>(&mut self, guard: G) -> &mut Self
where 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.

Source

pub fn clear_admission_guard(&mut self) -> &mut Self

Clear any configured admission guard.

Source

pub fn receipt_sink<S>(&mut self, sink: S) -> &mut Self
where S: ReceiptSink + 'static,

Configure the optional receipt sink made available to invocation contexts.

Source

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.

Source

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.

Source

pub fn status_sink<S>(&mut self, sink: S) -> &mut Self
where S: OperationStatusSink + Send + Sync + 'static,

Configure the optional operation-status sink used during checkout.

Source

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.

Source

pub fn clear_status_sink(&mut self) -> &mut Self

Clear any configured operation-status sink.

Source

pub fn receipt_hash_policy(&mut self, policy: ReceiptHashPolicy) -> &mut Self

Configure runtime receipt hash population.

Source

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.

Source

pub fn grant_capabilities<I, S>(&mut self, capabilities: I) -> &mut Self
where I: IntoIterator<Item = S>, S: Into<String>,

Grant several runtime capability tokens to the built Core.

Convenience over repeated Self::grant_capability calls; see it for the gate semantics.

Source

pub fn effect_backend<B>(&mut self, backend: B) -> &mut Self
where 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.

Source

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.

Source

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

Source§

fn default() -> CoreBuilder

Returns the “default value” for a type. Read more

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T> Instrument for T

Source§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
Source§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> IntoEither for T

Source§

fn into_either(self, into_left: bool) -> Either<Self, Self>

Converts 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 more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
where F: FnOnce(&Self) -> bool,

Converts 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
Source§

impl<T> Pointable for T

Source§

const ALIGN: usize

The alignment of pointer.
Source§

type Init = T

The type for initializers.
Source§

unsafe fn init(init: <T as Pointable>::Init) -> usize

Initializes a with the given initializer. Read more
Source§

unsafe fn deref<'a>(ptr: usize) -> &'a T

Dereferences the given pointer. Read more
Source§

unsafe fn deref_mut<'a>(ptr: usize) -> &'a mut T

Mutably dereferences the given pointer. Read more
Source§

unsafe fn drop(ptr: usize)

Drops the object pointed to by the given pointer. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<T> WithSubscriber for T

Source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more