pub struct Context<T> {Show 13 fields
pub trace_id: String,
pub identity: Identity,
pub services: T,
pub created_at: DateTime<Utc>,
pub caller_id: Option<String>,
pub data: HashMap<String, Value>,
pub parent_trace_id: Option<String>,
pub call_depth: u32,
pub call_chain: Vec<String>,
pub redacted_inputs: Option<HashMap<String, Value>>,
pub cancel_token: Option<CancelToken>,
pub trace_context: Option<TraceContext>,
pub executor: Option<Arc<dyn Any + Send + Sync>>,
}Expand description
Generic execution context carrying identity, services, and data.
Fields§
§trace_id: String§identity: Identity§services: T§created_at: DateTime<Utc>§caller_id: Option<String>§data: HashMap<String, Value>§parent_trace_id: Option<String>§call_depth: u32§call_chain: Vec<String>§redacted_inputs: Option<HashMap<String, Value>>§cancel_token: Option<CancelToken>§trace_context: Option<TraceContext>§executor: Option<Arc<dyn Any + Send + Sync>>Runtime reference to the executor for nested calls (not serialized).
Implementations§
Source§impl<T> Context<T>where
T: Default,
impl<T> Context<T>where
T: Default,
pub fn new(identity: Identity) -> Context<T>
Sourcepub fn child(&self, target_module_id: &str) -> Context<T>where
T: Clone,
pub fn child(&self, target_module_id: &str) -> Context<T>where
T: Clone,
Create a child context for nested calls.
Sourcepub fn from_json(data: Value) -> Result<Context<Value>, ModuleError>
pub fn from_json(data: Value) -> Result<Context<Value>, ModuleError>
Deserialize context from JSON.
Sourcepub fn logger(&self) -> ContextLogger
pub fn logger(&self) -> ContextLogger
Get a context-scoped logger.
Trait Implementations§
Source§impl<'de, T> Deserialize<'de> for Context<T>where
T: Deserialize<'de>,
impl<'de, T> Deserialize<'de> for Context<T>where
T: Deserialize<'de>,
Source§fn deserialize<__D>(
__deserializer: __D,
) -> Result<Context<T>, <__D as Deserializer<'de>>::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(
__deserializer: __D,
) -> Result<Context<T>, <__D as Deserializer<'de>>::Error>where
__D: Deserializer<'de>,
Deserialize this value from the given Serde deserializer. Read more
Source§impl<T> Serialize for Context<T>where
T: Serialize,
impl<T> Serialize for Context<T>where
T: Serialize,
Source§fn serialize<__S>(
&self,
__serializer: __S,
) -> Result<<__S as Serializer>::Ok, <__S as Serializer>::Error>where
__S: Serializer,
fn serialize<__S>(
&self,
__serializer: __S,
) -> Result<<__S as Serializer>::Ok, <__S as Serializer>::Error>where
__S: Serializer,
Serialize this value into the given Serde serializer. Read more
Auto Trait Implementations§
impl<T> Freeze for Context<T>where
T: Freeze,
impl<T> !RefUnwindSafe for Context<T>
impl<T> Send for Context<T>where
T: Send,
impl<T> Sync for Context<T>where
T: Sync,
impl<T> Unpin for Context<T>where
T: Unpin,
impl<T> UnsafeUnpin for Context<T>where
T: UnsafeUnpin,
impl<T> !UnwindSafe for Context<T>
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
Mutably borrows from an owned value. Read more