awaken_contract/contract/
active_agent.rs1pub struct ActiveAgentIdKey;
5
6impl crate::state::StateKey for ActiveAgentIdKey {
7 const KEY: &'static str = "__runtime.active_agent";
8 type Value = Option<String>;
9 type Update = Option<String>;
10
11 fn apply(value: &mut Self::Value, update: Self::Update) {
12 *value = update;
13 }
14}
15
16#[cfg(test)]
17mod tests {
18 use super::*;
19
20 #[test]
21 fn active_agent_key_apply() {
22 use crate::state::StateKey;
23 let mut val: Option<String> = None;
24 ActiveAgentIdKey::apply(&mut val, Some("reviewer".into()));
25 assert_eq!(val.as_deref(), Some("reviewer"));
26 ActiveAgentIdKey::apply(&mut val, None);
27 assert!(val.is_none());
28 }
29}