Skip to main content

ControlPolicy

Trait ControlPolicy 

Source
pub trait ControlPolicy: Send + Sync {
    // Required method
    fn name(&self) -> &'static str;

    // Provided methods
    fn enter_prompt(&self, _cx: &mut Cx, _prompt: &ControlPrompt) -> Result<()> { ... }
    fn capture(&self, cx: &mut Cx, _capture: &ControlCapture) -> Result<Ref> { ... }
    fn abort(&self, cx: &mut Cx, _abort: &ControlAbort) -> Result<Ref> { ... }
    fn resume(&self, cx: &mut Cx, _resume: &ControlResume) -> Result<Ref> { ... }
}
Expand description

Policy implementing delimited control: prompts, capture, abort, and resume.

The kernel defines this contract and the records it consumes; libraries supply the concrete continuation machinery. Unsupported operations report an “unsupported” control result rather than failing hard.

Required Methods§

Source

fn name(&self) -> &'static str

Stable name identifying the policy in diagnostics.

Provided Methods§

Source

fn enter_prompt(&self, _cx: &mut Cx, _prompt: &ControlPrompt) -> Result<()>

Enter a prompt boundary; the default is a no-op.

Source

fn capture(&self, cx: &mut Cx, _capture: &ControlCapture) -> Result<Ref>

Capture the continuation up to a prompt; defaults to unsupported.

Source

fn abort(&self, cx: &mut Cx, _abort: &ControlAbort) -> Result<Ref>

Abort to a prompt with a value; defaults to unsupported.

Source

fn resume(&self, cx: &mut Cx, _resume: &ControlResume) -> Result<Ref>

Resume a captured continuation with a value; defaults to unsupported.

Dyn Compatibility§

This trait is dyn compatible.

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

Implementors§