pub struct ChainContext {
pub responses: HashMap<String, ChainResponse>,
pub variables: HashMap<String, Value>,
pub metadata: HashMap<String, String>,
}
Expand description
Context store for maintaining state across a chain execution
Fields§
§responses: HashMap<String, ChainResponse>
Responses from previous requests in the chain
variables: HashMap<String, Value>
Global variables shared across the chain
metadata: HashMap<String, String>
Chain execution metadata
Implementations§
Source§impl ChainContext
impl ChainContext
Sourcepub fn store_response(&mut self, name: String, response: ChainResponse)
pub fn store_response(&mut self, name: String, response: ChainResponse)
Store a response with the given name
Sourcepub fn get_response(&self, name: &str) -> Option<&ChainResponse>
pub fn get_response(&self, name: &str) -> Option<&ChainResponse>
Get a stored response by name
Sourcepub fn set_variable(&mut self, name: String, value: Value)
pub fn set_variable(&mut self, name: String, value: Value)
Store a global variable
Sourcepub fn get_variable(&self, name: &str) -> Option<&Value>
pub fn get_variable(&self, name: &str) -> Option<&Value>
Get a global variable
Sourcepub fn set_metadata(&mut self, key: String, value: String)
pub fn set_metadata(&mut self, key: String, value: String)
Set metadata
Sourcepub fn get_metadata(&self, key: &str) -> Option<&String>
pub fn get_metadata(&self, key: &str) -> Option<&String>
Get metadata
Trait Implementations§
Source§impl Clone for ChainContext
impl Clone for ChainContext
Source§fn clone(&self) -> ChainContext
fn clone(&self) -> ChainContext
Returns a duplicate of the value. Read more
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source
. Read moreSource§impl Debug for ChainContext
impl Debug for ChainContext
Source§impl Default for ChainContext
impl Default for ChainContext
Source§impl<'de> Deserialize<'de> for ChainContext
impl<'de> Deserialize<'de> for ChainContext
Source§fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
Deserialize this value from the given Serde deserializer. Read more
Auto Trait Implementations§
impl Freeze for ChainContext
impl RefUnwindSafe for ChainContext
impl Send for ChainContext
impl Sync for ChainContext
impl Unpin for ChainContext
impl UnwindSafe for ChainContext
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