pub struct Context {
pub scope_value: Option<Value>,
pub scope_index: usize,
pub session_id: Option<String>,
/* private fields */
}Expand description
Tree-structured context that stores step outputs
Fields§
§scope_value: Option<Value>§scope_index: usize§session_id: Option<String>Implementations§
Source§impl Context
impl Context
pub fn new(target: String, vars: HashMap<String, Value>) -> Self
Sourcepub fn store(&mut self, name: &str, output: StepOutput)
pub fn store(&mut self, name: &str, output: StepOutput)
Store a step output
Sourcepub fn get_step(&self, name: &str) -> Option<&StepOutput>
pub fn get_step(&self, name: &str) -> Option<&StepOutput>
Get a step output (looks in parent if not found locally)
Sourcepub fn get_session(&self) -> Option<&str>
pub fn get_session(&self) -> Option<&str>
Get session ID (searches parent chain)
Sourcepub fn store_parsed(&mut self, name: &str, parsed: ParsedValue)
pub fn store_parsed(&mut self, name: &str, parsed: ParsedValue)
Store a parsed value for a step
Sourcepub fn get_parsed(&self, name: &str) -> Option<&ParsedValue>
pub fn get_parsed(&self, name: &str) -> Option<&ParsedValue>
Get a parsed value for a step (looks in parent if not found locally)
Sourcepub fn child(
parent: Arc<Context>,
scope_value: Option<Value>,
index: usize,
) -> Self
pub fn child( parent: Arc<Context>, scope_value: Option<Value>, index: usize, ) -> Self
Create a child context for a scope
Sourcepub fn get_from_value(&self, name: &str) -> Option<Value>
pub fn get_from_value(&self, name: &str) -> Option<Value>
Get the Tera-ready value for a step by name (used by from() preprocessing). Returns None if the step doesn’t exist in this context or any parent.
Sourcepub fn var_exists(&self, path: &str) -> bool
pub fn var_exists(&self, path: &str) -> bool
Check if a dotted path variable exists in this context (used for strict accessor)
Sourcepub fn get_chat_messages(&self, session: &str) -> Vec<ChatMessage>
pub fn get_chat_messages(&self, session: &str) -> Vec<ChatMessage>
Return all stored messages for a chat session (empty vec if session doesn’t exist)
Sourcepub fn append_chat_messages(&self, session: &str, messages: Vec<ChatMessage>)
pub fn append_chat_messages(&self, session: &str, messages: Vec<ChatMessage>)
Append messages to a chat session, creating the session if it doesn’t exist
Sourcepub fn to_tera_context(&self) -> Context
pub fn to_tera_context(&self) -> Context
Convert to Tera template context
Auto Trait Implementations§
impl Freeze for Context
impl RefUnwindSafe for Context
impl Send for Context
impl Sync for Context
impl Unpin for Context
impl UnsafeUnpin for Context
impl UnwindSafe for Context
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