basic_usage/
basic_usage.rs1use cirious_codex_result::{CodexOk, CodexOkRaw, ExecutionContext};
7
8#[cfg(feature = "serde")]
9use cirious_codex_result::log_codex_ok;
10
11pub fn example_dynamic_metadata() {
13 println!("--- Dynamic Metadata Example ---");
14
15 let result = CodexOk::new("Operation completed").with_meta("service", "auth");
17
18 println!("{result}");
19
20 #[cfg(feature = "serde")]
21 log_codex_ok(&result);
22}
23
24pub 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 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}
45
46fn main() {
47 example_dynamic_metadata();
48 example_typed_metadata();
49}