Skip to main content

CtxStorage

Trait CtxStorage 

Source
pub trait CtxStorage: Send + Sync {
    // Required methods
    fn read(&self, path: &str) -> Result<Value, EvalError>;
    fn write(&self, path: &str, value: Value) -> Result<(), EvalError>;
    fn snapshot(&self) -> Value;
    fn replace(&self, value: Value);
}
Expand description

Ctx backend trait — eval(_with_storage) 系が ctx state を touch する 唯一の経路。 &self write (interior mutability) で 走行中の Flow と 外部 task が同じ ctx を共有 できる (= dispatch().await suspend 中に外部 task が ctx.write で State 注入 → resume 後 Step が read で観測、 という dynamic injection 経路を成立させる)。

Default impl は MemoryCtx (Arc<Mutex<Value>> wrapper、 既存 serde_json::Value 直保持と挙動互換)。 consumer は typed struct / KV / 外部 store / observer wrap / event log 等を custom impl で持ち込める。

Required Methods§

Source

fn read(&self, path: &str) -> Result<Value, EvalError>

Read a single path ($.a.b.c 形式) from ctx.

Source

fn write(&self, path: &str, value: Value) -> Result<(), EvalError>

Write value to path ($.a.b.c 形式).

Source

fn snapshot(&self) -> Value

Take a snapshot of the entire ctx (= Expr eval / Fanout fork で使う pure read view).

Source

fn replace(&self, value: Value)

Replace the entire ctx with the given value (= Fanout branch restore 等).

Dyn Compatibility§

This trait is dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety".

Implementors§