Skip to main content

co_primitives/types/
guard.rs

1// SPDX-License-Identifier: AGPL-3.0-only
2// Copyright (C) 2026 1io BRANDGUARDIAN GmbH
3
4use crate::Tags;
5use cid::Cid;
6use serde::{Deserialize, Serialize};
7use std::collections::BTreeSet;
8
9#[derive(Debug, Serialize, Deserialize)]
10pub struct GuardInput {
11	/// Gurad name which references this guard in [`co_core_co::Co::guards`].
12	pub guard: String,
13
14	/// The state to check the guard against
15	pub state: Cid,
16
17	/// The heads that produced the state
18	pub heads: BTreeSet<Cid>,
19
20	/// The head to check
21	pub next_head: Cid,
22}
23
24#[derive(Debug, Serialize, Deserialize)]
25pub struct GuardOutput {
26	/// Gurad result.
27	pub result: bool,
28
29	/// Error if the guard has failed.
30	#[serde(default, skip_serializing_if = "Option::is_none")]
31	pub error: Option<String>,
32
33	/// Guard Metadata
34	#[serde(default, skip_serializing_if = "Tags::is_empty")]
35	pub tags: Tags,
36}