made_core/value_objects/ceremony/
context_patch.rs1use std::collections::BTreeMap;
2
3use serde::{Deserialize, Serialize};
4use serde_json::Value;
5
6use crate::error::DomainError;
7
8use super::ContextKey;
9
10#[derive(Debug, Clone, Default, PartialEq, Eq, Serialize, Deserialize)]
12#[serde(transparent)]
13pub struct ContextPatch(BTreeMap<ContextKey, Value>);
14
15impl ContextPatch {
16 pub fn new(entries: BTreeMap<ContextKey, Value>) -> Result<Self, DomainError> {
17 if entries.is_empty() {
18 return Err(DomainError::EmptyCollection {
19 field: "context_patch.entries",
20 });
21 }
22 Ok(Self(entries))
23 }
24
25 #[must_use]
26 pub fn entries(&self) -> &BTreeMap<ContextKey, Value> {
27 &self.0
28 }
29}