Struct zng::app::LocalContext
source · pub struct LocalContext { /* private fields */ }
Expand description
Tracks the current execution context.
The context tracks the current app, all or some context_local!
and TracingDispatcherContext
.
Implementations§
source§impl LocalContext
impl LocalContext
sourcepub const fn new() -> LocalContext
pub const fn new() -> LocalContext
New empty context.
sourcepub fn current_app() -> Option<AppId>
pub fn current_app() -> Option<AppId>
Get the ID of the app that owns the current context.
sourcepub fn register_cleanup(cleanup: impl FnOnce(AppId) + Send + 'static)
pub fn register_cleanup(cleanup: impl FnOnce(AppId) + Send + 'static)
Register to run when the app deinits and all clones of the app context are dropped.
sourcepub fn capture() -> LocalContext
pub fn capture() -> LocalContext
Capture a snapshot of the current context that can be restored in another thread to recreate the current context.
Context locals modified after this capture are not included in the capture.
This is equivalent to ``CaptureFilter::All`.
sourcepub fn capture_filtered(filter: CaptureFilter) -> LocalContext
pub fn capture_filtered(filter: CaptureFilter) -> LocalContext
Capture a snapshot of the current context that only includes filter
.
sourcepub fn value_set(&self) -> ContextValueSet
pub fn value_set(&self) -> ContextValueSet
Collects a set of all the values in the context.
sourcepub fn with_context<R>(&mut self, f: impl FnOnce() -> R) -> R
pub fn with_context<R>(&mut self, f: impl FnOnce() -> R) -> R
Calls f
in the captured context.
Note that this fully replaces the parent context for the duration of the f
call, see with_context_blend
for a blending alternative.
sourcepub fn with_context_blend<R>(&mut self, over: bool, f: impl FnOnce() -> R) -> R
pub fn with_context_blend<R>(&mut self, over: bool, f: impl FnOnce() -> R) -> R
Calls f
while all contextual values of self
are set on the parent context.
Unlike with_context
this does not remove values that are only set in the parent context, the
downside is that this call is more expensive.
If over
is true
all the values of self
are set over the parent values, if false
only
the values not already set in the parent are set.
sourcepub fn extend(&mut self, ctx: LocalContext)
pub fn extend(&mut self, ctx: LocalContext)
Blend ctx
over self
.
Trait Implementations§
source§impl Clone for LocalContext
impl Clone for LocalContext
source§fn clone(&self) -> LocalContext
fn clone(&self) -> LocalContext
1.0.0 · source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source
. Read moresource§impl Debug for LocalContext
impl Debug for LocalContext
source§impl Default for LocalContext
impl Default for LocalContext
source§fn default() -> LocalContext
fn default() -> LocalContext
Auto Trait Implementations§
impl Freeze for LocalContext
impl !RefUnwindSafe for LocalContext
impl Send for LocalContext
impl Sync for LocalContext
impl Unpin for LocalContext
impl !UnwindSafe for LocalContext
Blanket Implementations§
source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
source§unsafe fn clone_to_uninit(&self, dst: *mut T)
unsafe fn clone_to_uninit(&self, dst: *mut T)
clone_to_uninit
)§impl<T> Downcast for Twhere
T: Any,
impl<T> Downcast for Twhere
T: Any,
§fn into_any(self: Box<T>) -> Box<dyn Any>
fn into_any(self: Box<T>) -> Box<dyn Any>
Box<dyn Trait>
(where Trait: Downcast
) to Box<dyn Any>
. Box<dyn Any>
can
then be further downcast
into Box<ConcreteType>
where ConcreteType
implements Trait
.§fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
Rc<Trait>
(where Trait: Downcast
) to Rc<Any>
. Rc<Any>
can then be
further downcast
into Rc<ConcreteType>
where ConcreteType
implements Trait
.§fn as_any(&self) -> &(dyn Any + 'static)
fn as_any(&self) -> &(dyn Any + 'static)
&Trait
(where Trait: Downcast
) to &Any
. This is needed since Rust cannot
generate &Any
’s vtable from &Trait
’s.§fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
&mut Trait
(where Trait: Downcast
) to &Any
. This is needed since Rust cannot
generate &mut Any
’s vtable from &mut Trait
’s.§impl<T> DowncastSync for T
impl<T> DowncastSync for T
source§impl<T> FsChangeNote for T
impl<T> FsChangeNote for T
§impl<T> Instrument for T
impl<T> Instrument for T
§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
source§impl<T> Instrument for T
impl<T> Instrument for T
source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
source§impl<T> IntoEither for T
impl<T> IntoEither for T
source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
self
into a Left
variant of Either<Self, Self>
if into_left
is true
.
Converts self
into a Right
variant of Either<Self, Self>
otherwise. Read moresource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
self
into a Left
variant of Either<Self, Self>
if into_left(&self)
returns true
.
Converts self
into a Right
variant of Either<Self, Self>
otherwise. Read more§impl<T> NoneValue for Twhere
T: Default,
impl<T> NoneValue for Twhere
T: Default,
type NoneType = T
§fn null_value() -> T
fn null_value() -> T
§impl<T> NoneValue for Twhere
T: Default,
impl<T> NoneValue for Twhere
T: Default,
type NoneType = T
§fn null_value() -> T
fn null_value() -> T
§impl<T> Pointable for T
impl<T> Pointable for T
source§impl<R, P> ReadPrimitive<R> for P
impl<R, P> ReadPrimitive<R> for P
source§fn read_from_little_endian(read: &mut R) -> Result<Self, Error>
fn read_from_little_endian(read: &mut R) -> Result<Self, Error>
ReadEndian::read_from_little_endian()
.