snops_common/state/
agent_state.rs

1use super::{EnvId, NodeState};
2
3#[derive(Debug, Default, Clone, PartialEq, Eq, serde::Serialize, serde::Deserialize)]
4pub enum AgentState {
5    #[default]
6    // A node in the inventory can function as a transaction cannon
7    Inventory,
8    /// Test id mapping to node state
9    Node(EnvId, Box<NodeState>),
10}
11
12impl AgentState {
13    pub fn map_node<F>(self, f: F) -> AgentState
14    where
15        F: Fn(NodeState) -> NodeState,
16    {
17        match self {
18            Self::Inventory => Self::Inventory,
19            Self::Node(id, state) => Self::Node(id, Box::new(f(*state))),
20        }
21    }
22}