meerkat_runtime/
input_scope.rs1use serde::{Deserialize, Serialize};
4
5use crate::identifiers::LogicalRuntimeId;
6use meerkat_core::lifecycle::InputId;
7
8#[derive(Debug, Clone, PartialEq, Eq, Serialize, Deserialize)]
10#[serde(tag = "scope_type", rename_all = "snake_case")]
11#[non_exhaustive]
12pub enum InputScope {
13 Runtime { runtime_id: LogicalRuntimeId },
15 Specific { input_id: InputId },
17 All,
19}
20
21#[cfg(test)]
22#[allow(clippy::unwrap_used)]
23mod tests {
24 use super::*;
25
26 #[test]
27 fn input_scope_runtime_serde() {
28 let scope = InputScope::Runtime {
29 runtime_id: LogicalRuntimeId::new("agent-1"),
30 };
31 let json = serde_json::to_value(&scope).unwrap();
32 assert_eq!(json["scope_type"], "runtime");
33 let parsed: InputScope = serde_json::from_value(json).unwrap();
34 assert_eq!(scope, parsed);
35 }
36
37 #[test]
38 fn input_scope_specific_serde() {
39 let scope = InputScope::Specific {
40 input_id: InputId::new(),
41 };
42 let json = serde_json::to_value(&scope).unwrap();
43 assert_eq!(json["scope_type"], "specific");
44 let parsed: InputScope = serde_json::from_value(json).unwrap();
45 assert_eq!(scope, parsed);
46 }
47
48 #[test]
49 fn input_scope_all_serde() {
50 let scope = InputScope::All;
51 let json = serde_json::to_value(&scope).unwrap();
52 assert_eq!(json["scope_type"], "all");
53 let parsed: InputScope = serde_json::from_value(json).unwrap();
54 assert_eq!(scope, parsed);
55 }
56}