pub trait ScriptContext: Send {
// Required methods
fn label(&self) -> &str;
fn actor_json(&self) -> &Value;
}Expand description
Opaque execution context for script handlers.
The runtime passes this as the first argument to #[chronon::script] handlers and to
registered invoke functions. Use Self::label for logs and Self::actor_json when the
handler only needs the captured actor payload from crate::models::Job::actor_json.
§Examples
use chronon_core::{ContextFactory, JsonScriptContextFactory, ScriptContext};
use serde_json::json;
let ctx = JsonScriptContextFactory
.build(&json!({"user": "alice"}))
.unwrap();
assert!(ctx.label().contains("alice"));
assert_eq!(ctx.actor_json()["user"], "alice");Required Methods§
Sourcefn actor_json(&self) -> &Value
fn actor_json(&self) -> &Value
Actor JSON captured at schedule time and restored at dispatch.
Dyn Compatibility§
This trait is dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety".