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§
Sourcetype Frame
type Frame
The type of frame returned by Ctxt::open_root
and Ctxt::open_push
.
Required Methods§
Sourcefn open_root<P: Props>(&self, props: P) -> Self::Frame
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
.
Sourcefn enter(&self, frame: &mut Self::Frame)
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.
Sourcefn with_current<R, F: FnOnce(&Self::Current) -> R>(&self, with: F) -> R
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.
Sourcefn exit(&self, frame: &mut Self::Frame)
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.
Provided Methods§
Sourcefn open_push<P: Props>(&self, props: P) -> Self::Frame
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
.
Sourcefn open_disabled<P: Props>(&self, props: P) -> Self::Frame
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.