use crate::context::ContextKey;
use crate::fact::ProposedFact;
#[derive(Debug, Default)]
pub struct AgentEffect {
pub proposals: Vec<ProposedFact>,
}
impl AgentEffect {
#[must_use]
pub fn empty() -> Self {
Self::default()
}
#[must_use]
pub fn with_proposal(proposal: ProposedFact) -> Self {
Self {
proposals: vec![proposal],
}
}
#[must_use]
pub fn with_proposals(proposals: Vec<ProposedFact>) -> Self {
Self { proposals }
}
#[must_use]
pub fn is_empty(&self) -> bool {
self.proposals.is_empty()
}
#[must_use]
pub fn affected_keys(&self) -> Vec<ContextKey> {
let mut keys: Vec<ContextKey> = self.proposals.iter().map(|p| p.key).collect();
keys.sort();
keys.dedup();
keys
}
}