modality_mutator_protocol/
actuator.rs

1use async_trait::async_trait;
2
3use crate::attrs::{AttrKey, AttrVal};
4use std::collections::BTreeMap;
5
6/// "Infallible" operational view on a mutator actuator.
7#[async_trait]
8pub trait MutatorActuator {
9    /// Input params attribute iterator should not contain duplicate keys.
10    /// It is effectively a map of key-value pairs.
11    ///
12    /// The keys are expected to be of either format:
13    ///   * `<param-key>`
14    ///   * OR `mutator.params.<param-key>`
15    async fn inject(
16        &mut self,
17        mutation_id: uuid::Uuid,
18        params: BTreeMap<AttrKey, AttrVal>,
19    ) -> Result<(), Box<dyn std::error::Error + Send + Sync>>;
20
21    async fn reset(&mut self) -> Result<(), Box<dyn std::error::Error + Send + Sync>>;
22}
23
24/// A non-async version of MutatorActuator. This isn't supported by the provided http server, but
25/// may be useful if the abstraction is needed in other host contexts.
26pub trait SyncMutatorActuator {
27    /// Input params attribute iterator should not contain duplicate keys.
28    /// It is effectively a map of key-value pairs.
29    ///
30    /// The keys are expected to be of either format:
31    ///   * `<param-key>`
32    ///   * OR `mutator.params.<param-key>`
33    fn inject(
34        &mut self,
35        mutation_id: uuid::Uuid,
36        params: BTreeMap<AttrKey, AttrVal>,
37    ) -> Result<(), Box<dyn std::error::Error>>;
38
39    fn reset(&mut self) -> Result<(), Box<dyn std::error::Error>>;
40}