pub struct CompensationRegistry { /* private fields */ }Expand description
The registry of rollback handlers backing admit_compensatable.
Registration is the mechanism that makes a Compensatable declaration
meaningful: the handler for an effect kind must exist before the effect
executes, so the undo path is a precondition, not a postmortem. Handlers
are keyed by TypedEffect::kind; re-registering a kind replaces its
handler (and returns the old one) so deployments can evolve compensation
logic deliberately.
Implementations§
Source§impl CompensationRegistry
impl CompensationRegistry
Sourcepub fn new() -> Self
pub fn new() -> Self
An empty registry: every Compensatable admission fails until a
handler is registered — the fail-closed default.
Sourcepub fn register(
&mut self,
kind: impl Into<String>,
handler: CompensationHandler,
) -> Option<CompensationHandler>
pub fn register( &mut self, kind: impl Into<String>, handler: CompensationHandler, ) -> Option<CompensationHandler>
Register handler as the rollback path for kind, returning the
handler it replaced, if any.
Sourcepub fn handler_for(&self, kind: &str) -> Option<&CompensationHandler>
pub fn handler_for(&self, kind: &str) -> Option<&CompensationHandler>
The handler registered for kind, if any.
Trait Implementations§
Source§impl Clone for CompensationRegistry
impl Clone for CompensationRegistry
Source§impl Debug for CompensationRegistry
impl Debug for CompensationRegistry
Auto Trait Implementations§
impl !RefUnwindSafe for CompensationRegistry
impl !UnwindSafe for CompensationRegistry
impl Freeze for CompensationRegistry
impl Send for CompensationRegistry
impl Sync for CompensationRegistry
impl Unpin for CompensationRegistry
impl UnsafeUnpin for CompensationRegistry
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
Mutably borrows from an owned value. Read more