Struct apalis_core::context::JobContext
source · [−]pub struct JobContext { /* private fields */ }Expand description
The context for a job is represented here Used to provide a context when a job is defined through the Job trait
Implementations
sourceimpl JobContext
impl JobContext
pub fn new() -> Self
sourcepub fn data_opt<D: Any + Send + Sync>(&self) -> Option<&D>
pub fn data_opt<D: Any + Send + Sync>(&self) -> Option<&D>
Get a reference to a type previously inserted on this JobContext.
Example
let mut ctx = JobContext::new();
assert!(ctx.data_opt::<i32>().is_none());
ctx.insert(5i32);
assert_eq!(ctx.data_opt::<i32>(), Some(&5i32));sourcepub fn insert<D: Any + Send + Sync>(&mut self, data: D) -> Option<D>
pub fn insert<D: Any + Send + Sync>(&mut self, data: D) -> Option<D>
Insert a type into this JobContext.
Important for embedding data for a job. If a extension of this type already existed, it will be returned.
Example
let mut ctx = JobContext::new();
assert!(ctx.insert(5i32).is_none());
assert!(ctx.insert(4u8).is_none());
assert_eq!(ctx.insert(9i32), Some(5i32));Trait Implementations
sourceimpl Debug for JobContext
impl Debug for JobContext
Auto Trait Implementations
impl !RefUnwindSafe for JobContext
impl Send for JobContext
impl Sync for JobContext
impl Unpin for JobContext
impl !UnwindSafe for JobContext
Blanket Implementations
sourceimpl<T> BorrowMut<T> for T where
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
const: unstable · sourcefn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
sourceimpl<T> Instrument for T
impl<T> Instrument for T
sourcefn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
sourcefn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
sourceimpl<T> WithSubscriber for T
impl<T> WithSubscriber for T
sourcefn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self> where
S: Into<Dispatch>,
fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self> where
S: Into<Dispatch>,
Attaches the provided Subscriber to this type, returning a
WithDispatch wrapper. Read more
sourcefn with_current_subscriber(self) -> WithDispatch<Self>
fn with_current_subscriber(self) -> WithDispatch<Self>
Attaches the current default Subscriber to this type, returning a
WithDispatch wrapper. Read more