Skip to main content

EffectGate

Struct EffectGate 

Source
pub struct EffectGate { /* private fields */ }
Expand description

The single admission authority for one control surface. Cheap to share behind an Arc; admit is safe to call concurrently.

Implementations§

Source§

impl EffectGate

Source

pub fn new(hook: impl AdmissionHook + 'static) -> Self

Source

pub fn from_arc(hook: Arc<dyn AdmissionHook>) -> Self

Source

pub fn allow_all() -> Self

Gate with AllowAll: still validates, settles and emits events.

Source

pub fn with_events(self, sink: EventSink) -> Self

Source

pub fn with_journal_capacity(self, capacity: usize) -> Self

Bound on retained settlements (oldest dropped first). 0 keeps none.

Source

pub fn settlements(&self) -> Vec<Settlement>

Snapshot of retained settlements, oldest first.

Source

pub fn admit<T>( &self, request: EffectRequest, cancel: &CancelToken, execute: impl FnOnce(&CancelToken) -> Result<T, ExecError>, ) -> Effect<T>

Run request through validate → approval → execute → settle.

execute is invoked at most once, and only when validation and the hook both admit the request and cancel is not yet set. Every path settles exactly once (recorded and returned) and emits lifecycle events. Executor panics are contained and settled as Failed.

Trait Implementations§

Source§

impl Debug for EffectGate

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl Default for EffectGate

Source§

fn default() -> Self

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, 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, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = !

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

fn try_from(value: U) -> Result<T, !>

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.