Skip to main content

CallbackPolicy

Trait CallbackPolicy 

Source
pub trait CallbackPolicy: Clone + 'static {
    // Required methods
    fn capture(ctx: &Ctx<'_>) -> Option<Self>
       where Self: Sized;
    fn enter<R>(
        ctx: &Ctx<'_>,
        policy: Option<&Self>,
        f: impl FnOnce() -> R,
    ) -> R
       where Self: Sized;
}
Expand description

Ambient host state that a scheduled callback must run under.

Required Methods§

Source

fn capture(ctx: &Ctx<'_>) -> Option<Self>
where Self: Sized,

The state in force right now, if any.

Source

fn enter<R>(ctx: &Ctx<'_>, policy: Option<&Self>, f: impl FnOnce() -> R) -> R
where Self: Sized,

Run f with policy in force, restoring the caller’s state after.

Dyn Compatibility§

This trait is not dyn compatible.

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

Implementors§