emit_core::ctxt

Trait Ctxt

Source
pub trait Ctxt {
    type Current: Props + ?Sized;
    type Frame;

    // Required methods
    fn open_root<P: Props>(&self, props: P) -> Self::Frame;
    fn enter(&self, frame: &mut Self::Frame);
    fn with_current<R, F: FnOnce(&Self::Current) -> R>(&self, with: F) -> R;
    fn exit(&self, frame: &mut Self::Frame);
    fn close(&self, frame: Self::Frame);

    // Provided methods
    fn open_push<P: Props>(&self, props: P) -> Self::Frame { ... }
    fn open_disabled<P: Props>(&self, props: P) -> Self::Frame { ... }
}
Expand description

Storage for ambient Props.

Required Associated Types§

Source

type Current: Props + ?Sized

The type of Props used in Ctxt::with_current.

Source

type Frame

The type of frame returned by Ctxt::open_root and Ctxt::open_push.

Required Methods§

Source

fn open_root<P: Props>(&self, props: P) -> Self::Frame

Create a frame that will set the context to just the properties in P.

This method can be used to delete properties from the context, by pushing a frame that includes the current set with unwanted properties removed.

Once a frame is created, it can be entered to make its properties live by passing it to Ctxt::enter. The frame needs to be exited on the same thread by a call to Ctxt::exit. Once it’s done, it should be disposed by a call to Ctxt::close.

Source

fn enter(&self, frame: &mut Self::Frame)

Make the properties in a frame active.

Once a frame is entered, it must be exited by a call to Ctxt::exit on the same thread.

Source

fn with_current<R, F: FnOnce(&Self::Current) -> R>(&self, with: F) -> R

Access the current context.

The properties passed to with are those from the most recently entered frame.

This method must call with exactly once, even if the current context is empty.

Source

fn exit(&self, frame: &mut Self::Frame)

Make the properties in a frame inactive.

Once a frame is exited, it can be entered again with a new call to Ctxt::enter, potentially on another thread if Ctxt::Frame allows it.

Source

fn close(&self, frame: Self::Frame)

Close a frame, performing any shared cleanup.

This method should be called whenever a frame is finished. Failing to do so may leak.

Provided Methods§

Source

fn open_push<P: Props>(&self, props: P) -> Self::Frame

Create a frame that will set the context to its current set, plus the properties in P.

Once a frame is created, it can be entered to make its properties live by passing it to Ctxt::enter. The frame needs to be exited on the same thread by a call to Ctxt::exit. Once it’s done, it should be disposed by a call to Ctxt::close.

Source

fn open_disabled<P: Props>(&self, props: P) -> Self::Frame

Create a disabled frame.

The properties in P will not be made live when the frame is entered but may still be tracked by the underlying context using the returned frame. This method can be used to inform a context about properties that would have been used under some other conditions.

Dyn Compatibility§

This trait is not dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.

Implementations on Foreign Types§

Source§

impl<'a, C: Ctxt + ?Sized + 'a> Ctxt for Box<C>

Source§

type Current = <C as Ctxt>::Current

Source§

type Frame = <C as Ctxt>::Frame

Source§

fn with_current<R, F: FnOnce(&Self::Current) -> R>(&self, with: F) -> R

Source§

fn open_root<P: Props>(&self, props: P) -> Self::Frame

Source§

fn open_push<P: Props>(&self, props: P) -> Self::Frame

Source§

fn open_disabled<P: Props>(&self, props: P) -> Self::Frame

Source§

fn enter(&self, frame: &mut Self::Frame)

Source§

fn exit(&self, frame: &mut Self::Frame)

Source§

fn close(&self, frame: Self::Frame)

Source§

impl<'a, C: Ctxt + ?Sized + 'a> Ctxt for Arc<C>

Source§

type Current = <C as Ctxt>::Current

Source§

type Frame = <C as Ctxt>::Frame

Source§

fn with_current<R, F: FnOnce(&Self::Current) -> R>(&self, with: F) -> R

Source§

fn open_root<P: Props>(&self, props: P) -> Self::Frame

Source§

fn open_push<P: Props>(&self, props: P) -> Self::Frame

Source§

fn open_disabled<P: Props>(&self, props: P) -> Self::Frame

Source§

fn enter(&self, frame: &mut Self::Frame)

Source§

fn exit(&self, frame: &mut Self::Frame)

Source§

fn close(&self, frame: Self::Frame)

Source§

impl<'a, C: Ctxt + ?Sized> Ctxt for &'a C

Source§

type Current = <C as Ctxt>::Current

Source§

type Frame = <C as Ctxt>::Frame

Source§

fn open_root<P: Props>(&self, props: P) -> Self::Frame

Source§

fn open_push<P: Props>(&self, props: P) -> Self::Frame

Source§

fn open_disabled<P: Props>(&self, props: P) -> Self::Frame

Source§

fn enter(&self, frame: &mut Self::Frame)

Source§

fn with_current<R, F: FnOnce(&Self::Current) -> R>(&self, with: F) -> R

Source§

fn exit(&self, frame: &mut Self::Frame)

Source§

fn close(&self, frame: Self::Frame)

Source§

impl<C: Ctxt> Ctxt for Option<C>

Source§

type Current = Option<Slot<<C as Ctxt>::Current>>

Source§

type Frame = Option<<C as Ctxt>::Frame>

Source§

fn with_current<R, F: FnOnce(&Self::Current) -> R>(&self, with: F) -> R

Source§

fn open_root<P: Props>(&self, props: P) -> Self::Frame

Source§

fn open_push<P: Props>(&self, props: P) -> Self::Frame

Source§

fn open_disabled<P: Props>(&self, props: P) -> Self::Frame

Source§

fn enter(&self, frame: &mut Self::Frame)

Source§

fn exit(&self, frame: &mut Self::Frame)

Source§

fn close(&self, frame: Self::Frame)

Implementors§

Source§

impl Ctxt for Empty

Source§

impl<'a> Ctxt for dyn ErasedCtxt + 'a

Source§

type Current = ErasedCurrent

Source§

type Frame = ErasedFrame

Source§

impl<'a> Ctxt for dyn ErasedCtxt + Send + Sync + 'a

Source§

type Current = <dyn ErasedCtxt + 'a as Ctxt>::Current

Source§

type Frame = <dyn ErasedCtxt + 'a as Ctxt>::Frame

Source§

impl<T: Ctxt> Ctxt for AssertInternal<T>

Source§

type Current = <T as Ctxt>::Current

Source§

type Frame = <T as Ctxt>::Frame