Skip to main content

PreparedSet

Trait PreparedSet 

Source
pub trait PreparedSet: Send + 'static {
    // Required methods
    fn commit<'a>(
        &'a mut self,
        ctx: &'a RequestContext,
        oid: &'a Oid,
        value: &'a Value,
    ) -> BoxFuture<'a, SetCommitResult>;
    fn undo<'a>(
        &'a mut self,
        ctx: &'a RequestContext,
        oid: &'a Oid,
        value: &'a Value,
    ) -> BoxFuture<'a, SetUndoResult>;

    // Provided methods
    fn free<'a>(
        &'a mut self,
        _ctx: &'a RequestContext,
        _oid: &'a Oid,
        _value: &'a Value,
    ) -> BoxFuture<'a, ()> { ... }
    fn finalize<'a>(
        &'a mut self,
        _ctx: &'a RequestContext,
        _oid: &'a Oid,
        _value: &'a Value,
    ) -> BoxFuture<'a, ()> { ... }
}
Available on crate feature agent only.
Expand description

Request-owned state for one successfully tested SET varbind.

Implementations keep reservations, validated values, and rollback data in this object. The agent stores heterogeneous prepared objects until every varbind has passed MibHandler::test_set, then drives the remaining phases in RFC order.

The explicit async terminal methods undo, free, and finalize perform protocol cleanup during normal execution. Cooperative request cancellation before commit runs free; after commit starts the Agent protects all remaining phases from its retrieval-only abort policy. Drop is only a synchronous fallback for a panic or an out-of-band task abort and cannot guarantee transactional atomicity once commit has started.

Terminal methods must disarm the Drop fallback before creating a future that can reach an .await. Store fallback state in an Option, call take() synchronously in the method body, then move the taken state into the returned future. Drop must be idempotent when that Option is already empty. The agent retains the prepared object while each callback runs and drops all still-owned objects in reverse varbind order on an out-of-band abort.

Required Methods§

Source

fn commit<'a>( &'a mut self, ctx: &'a RequestContext, oid: &'a Oid, value: &'a Value, ) -> BoxFuture<'a, SetCommitResult>

Apply the prepared change.

The agent retains ownership of this object after a successful commit so an earlier change can still be undone if a later binding fails. A failure may follow partial mutation and is followed by undo. A commit that cooperatively reacts to request cancellation may return a normal failure only if it retains enough state for that undo lifecycle.

Source

fn undo<'a>( &'a mut self, ctx: &'a RequestContext, oid: &'a Oid, value: &'a Value, ) -> BoxFuture<'a, SetUndoResult>

Roll back an attempted commit and release its reservation.

Disarm synchronous fallback state before returning the future. On an out-of-band task abort, the future and then the still-owned prepared object are dropped; Drop must tolerate the already-disarmed state. Agent deadline or shutdown cancellation does not interrupt this protected callback: it must run to completion. Cleanup that performs I/O must provide its own bounded or durable recovery mechanism rather than abandoning rollback when the request token is cancelled.

Provided Methods§

Source

fn free<'a>( &'a mut self, _ctx: &'a RequestContext, _oid: &'a Oid, _value: &'a Value, ) -> BoxFuture<'a, ()>

Release a reservation whose commit was never attempted.

Disarm synchronous fallback state before returning the future. Override this when releasing a reservation must await I/O. Agent deadline or shutdown cancellation does not interrupt this protected callback. I/O-backed cleanup must use its own bounded or durable recovery mechanism and still complete the ownership transfer.

Source

fn finalize<'a>( &'a mut self, _ctx: &'a RequestContext, _oid: &'a Oid, _value: &'a Value, ) -> BoxFuture<'a, ()>

Release rollback data and reservations after every commit succeeds.

This is the successful terminal path. It does not roll back the applied value. As with undo and free, take Option-held fallback state synchronously before returning a future that may await. Agent deadline or shutdown cancellation does not interrupt this protected callback. I/O-backed cleanup must use its own bounded or durable recovery mechanism and still complete.

Dyn Compatibility§

This trait is dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety".

Implementors§