Skip to main content

Module context

Module context 

Source
Expand description

Type-safe context for storing request-scoped data.

This module provides type-erased containers for storing arbitrary data during event processing. Values are stored and retrieved by their Rust type.

§Types

  • Context - Single-threaded type map (not Send/Sync)
  • RwContext - Thread-safe version wrapped in Arc<RwLock<_>>
  • Data - Arc-wrapped shared data for cloneable access

§Example

use evento::context::{RwContext, Data};

// Create a context
let ctx = RwContext::new();

// Store data by type
ctx.insert(Data::new(MyAppState { ... }));
ctx.insert(42u32);

// Retrieve data by type
let state: Data<MyAppState> = ctx.extract();
let number: u32 = ctx.get().unwrap();

Structs§

Context
A type map for storing request-scoped data.
Data
Arc-wrapped shared data for use in contexts.
RwContext
Thread-safe context for storing request-scoped data.