pub struct ExecutionContext {
pub duration_ms: u64,
pub affected_rows: usize,
pub process_id: u32,
}Expand description
Represents the structured diagnostic context for a successful operation.
This struct is intended to be used as the generic metadata context C within
a CodexOkRaw instance. It provides standard fields for
tracking common performance and identity metrics across your application.
§Fields
duration_ms- The time taken for the operation to complete, in milliseconds.affected_rows- The number of database rows, file records, or entities modified.process_id- The unique identifier of the process or worker thread that performed the task.
Fields§
§duration_ms: u64The time taken for the operation to complete, in milliseconds.
affected_rows: usizeThe number of database rows, file records, or entities modified.
process_id: u32The unique identifier of the process or worker thread that performed the task.
Implementations§
Source§impl ExecutionContext
impl ExecutionContext
Sourcepub fn new() -> Self
pub fn new() -> Self
Creates a new ExecutionContext with default values.
This is the canonical way to create a default context when the
default method is not directly accessible or for explicit clarity.
Examples found in repository?
examples/basic_usage.rs (line 28)
25pub fn example_typed_metadata() {
26 println!("\n--- Typed Metadata Example ---");
27
28 let ctx = ExecutionContext::new()
29 .with_duration(150)
30 .with_affected_rows(12)
31 .with_process_id(9982);
32
33 // Provide explicit type here so the compiler knows C is ExecutionContext
34 let result: CodexOkRaw<String, ExecutionContext> = CodexOkRaw {
35 value: "Batch processing completed".to_string(),
36 location: std::panic::Location::caller(),
37 execution_meta: ctx,
38 };
39
40 println!("{result}");
41
42 #[cfg(feature = "serde")]
43 log_codex_ok(&result);
44}Sourcepub const fn with_duration(self, duration_ms: u64) -> Self
pub const fn with_duration(self, duration_ms: u64) -> Self
Sets the duration of the operation.
Examples found in repository?
examples/basic_usage.rs (line 29)
25pub fn example_typed_metadata() {
26 println!("\n--- Typed Metadata Example ---");
27
28 let ctx = ExecutionContext::new()
29 .with_duration(150)
30 .with_affected_rows(12)
31 .with_process_id(9982);
32
33 // Provide explicit type here so the compiler knows C is ExecutionContext
34 let result: CodexOkRaw<String, ExecutionContext> = CodexOkRaw {
35 value: "Batch processing completed".to_string(),
36 location: std::panic::Location::caller(),
37 execution_meta: ctx,
38 };
39
40 println!("{result}");
41
42 #[cfg(feature = "serde")]
43 log_codex_ok(&result);
44}Sourcepub const fn with_affected_rows(self, affected_rows: usize) -> Self
pub const fn with_affected_rows(self, affected_rows: usize) -> Self
Sets the number of affected rows.
Examples found in repository?
examples/basic_usage.rs (line 30)
25pub fn example_typed_metadata() {
26 println!("\n--- Typed Metadata Example ---");
27
28 let ctx = ExecutionContext::new()
29 .with_duration(150)
30 .with_affected_rows(12)
31 .with_process_id(9982);
32
33 // Provide explicit type here so the compiler knows C is ExecutionContext
34 let result: CodexOkRaw<String, ExecutionContext> = CodexOkRaw {
35 value: "Batch processing completed".to_string(),
36 location: std::panic::Location::caller(),
37 execution_meta: ctx,
38 };
39
40 println!("{result}");
41
42 #[cfg(feature = "serde")]
43 log_codex_ok(&result);
44}Sourcepub const fn with_process_id(self, process_id: u32) -> Self
pub const fn with_process_id(self, process_id: u32) -> Self
Sets the process ID.
Examples found in repository?
examples/basic_usage.rs (line 31)
25pub fn example_typed_metadata() {
26 println!("\n--- Typed Metadata Example ---");
27
28 let ctx = ExecutionContext::new()
29 .with_duration(150)
30 .with_affected_rows(12)
31 .with_process_id(9982);
32
33 // Provide explicit type here so the compiler knows C is ExecutionContext
34 let result: CodexOkRaw<String, ExecutionContext> = CodexOkRaw {
35 value: "Batch processing completed".to_string(),
36 location: std::panic::Location::caller(),
37 execution_meta: ctx,
38 };
39
40 println!("{result}");
41
42 #[cfg(feature = "serde")]
43 log_codex_ok(&result);
44}Trait Implementations§
Source§impl Debug for ExecutionContext
impl Debug for ExecutionContext
Source§impl Default for ExecutionContext
impl Default for ExecutionContext
Source§fn default() -> ExecutionContext
fn default() -> ExecutionContext
Returns the “default value” for a type. Read more
Source§impl<'de> Deserialize<'de> for ExecutionContextwhere
ExecutionContext: Default,
impl<'de> Deserialize<'de> for ExecutionContextwhere
ExecutionContext: Default,
Source§fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
Deserialize this value from the given Serde deserializer. Read more
Auto Trait Implementations§
impl Freeze for ExecutionContext
impl RefUnwindSafe for ExecutionContext
impl Send for ExecutionContext
impl Sync for ExecutionContext
impl Unpin for ExecutionContext
impl UnsafeUnpin for ExecutionContext
impl UnwindSafe for ExecutionContext
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
Source§impl<T> CodexOkWrap for T
impl<T> CodexOkWrap for T
Source§fn into_codex(self) -> CodexOkRaw<T>
fn into_codex(self) -> CodexOkRaw<T>
Wraps the current value into a
CodexOkRaw, natively capturing the caller location.