pub struct ActionContext {
pub objects: HashMap<String, Object>,
pub parameters: HashMap<String, Value>,
pub metadata: HashMap<String, String>,
}Expand description
Context passed to actions containing relevant objects and traits
Fields§
§objects: HashMap<String, Object>Objects relevant to this action
parameters: HashMap<String, Value>Additional parameters for the action
metadata: HashMap<String, String>Metadata about the action execution
Implementations§
Source§impl ActionContext
impl ActionContext
Sourcepub fn with_capacity(
expected_objects: usize,
expected_parameters: usize,
) -> Self
pub fn with_capacity( expected_objects: usize, expected_parameters: usize, ) -> Self
Create a new action context with expected capacity
Sourcepub fn add_object(&mut self, name: impl Into<String>, object: Object)
pub fn add_object(&mut self, name: impl Into<String>, object: Object)
Add an object to the context
Sourcepub fn get_object(&self, name: &str) -> Option<&Object>
pub fn get_object(&self, name: &str) -> Option<&Object>
Get an object from the context
Sourcepub fn get_objects(&self, names: &[&str]) -> HashMap<String, &Object>
pub fn get_objects(&self, names: &[&str]) -> HashMap<String, &Object>
Get multiple objects efficiently
Sourcepub fn add_parameter(&mut self, name: impl Into<String>, value: Value)
pub fn add_parameter(&mut self, name: impl Into<String>, value: Value)
Add a parameter to the context
Sourcepub fn get_parameter(&self, name: &str) -> Option<&Value>
pub fn get_parameter(&self, name: &str) -> Option<&Value>
Get a parameter from the context
Sourcepub fn add_metadata(&mut self, key: impl Into<String>, value: impl Into<String>)
pub fn add_metadata(&mut self, key: impl Into<String>, value: impl Into<String>)
Add metadata to the context
Sourcepub fn get_metadata(&self, key: &str) -> Option<&String>
pub fn get_metadata(&self, key: &str) -> Option<&String>
Get metadata from the context
Sourcepub fn object_count(&self) -> usize
pub fn object_count(&self) -> usize
Get object count
Sourcepub fn parameter_count(&self) -> usize
pub fn parameter_count(&self) -> usize
Get parameter count
Sourcepub fn metadata_count(&self) -> usize
pub fn metadata_count(&self) -> usize
Get metadata count
Sourcepub fn reserve_objects(&mut self, additional: usize)
pub fn reserve_objects(&mut self, additional: usize)
Reserve capacity for objects
Sourcepub fn reserve_parameters(&mut self, additional: usize)
pub fn reserve_parameters(&mut self, additional: usize)
Reserve capacity for parameters
Sourcepub fn clear_objects(&mut self)
pub fn clear_objects(&mut self)
Clear all objects
Sourcepub fn clear_parameters(&mut self)
pub fn clear_parameters(&mut self)
Clear all parameters
Sourcepub fn clear_metadata(&mut self)
pub fn clear_metadata(&mut self)
Clear all metadata
Trait Implementations§
Source§impl Clone for ActionContext
impl Clone for ActionContext
Source§fn clone(&self) -> ActionContext
fn clone(&self) -> ActionContext
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 ActionContext
impl Debug for ActionContext
Auto Trait Implementations§
impl Freeze for ActionContext
impl RefUnwindSafe for ActionContext
impl Send for ActionContext
impl Sync for ActionContext
impl Unpin for ActionContext
impl UnwindSafe for ActionContext
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