ergo_runtime/action/implementations/context_set_series/
impl.rs1use std::collections::HashMap;
2
3use crate::action::{
4 ActionOutcome, ActionPrimitive, ActionPrimitiveManifest, ActionValue, ParameterValue,
5};
6
7use super::manifest::context_set_series_manifest;
8
9pub struct ContextSetSeriesAction {
10 manifest: ActionPrimitiveManifest,
11}
12
13impl ContextSetSeriesAction {
14 pub fn new() -> Self {
15 Self {
16 manifest: context_set_series_manifest(),
17 }
18 }
19}
20
21impl Default for ContextSetSeriesAction {
22 fn default() -> Self {
23 Self::new()
24 }
25}
26
27impl ActionPrimitive for ContextSetSeriesAction {
28 fn manifest(&self) -> &ActionPrimitiveManifest {
29 &self.manifest
30 }
31
32 fn execute(
33 &self,
34 inputs: &HashMap<String, ActionValue>,
35 _parameters: &HashMap<String, ParameterValue>,
36 ) -> HashMap<String, ActionValue> {
37 let _event = inputs
38 .get("event")
39 .and_then(|v| v.as_event())
40 .expect("missing required event input 'event'");
41
42 let _value = inputs
43 .get("value")
44 .and_then(|v| v.as_series())
45 .expect("missing required series input 'value'");
46
47 HashMap::from([(
48 "outcome".to_string(),
49 ActionValue::Event(ActionOutcome::Attempted),
50 )])
51 }
52}