Skip to main content

co_primitives/types/
entry.rs

1// SPDX-License-Identifier: AGPL-3.0-only
2// Copyright (C) 2026 1io BRANDGUARDIAN GmbH
3
4use crate::Clock;
5use cid::Cid;
6use serde::{Deserialize, Serialize};
7use std::collections::BTreeSet;
8
9#[derive(Debug, Clone, Serialize, Deserialize, PartialEq)]
10pub struct Entry {
11	/// The stream id.
12	/// Todo: Do we need this?
13	#[serde(rename = "i", with = "serde_bytes")]
14	pub id: Vec<u8>,
15	#[serde(rename = "p")]
16	pub payload: Cid,
17	#[serde(rename = "n")]
18	pub next: BTreeSet<Cid>,
19	#[serde(rename = "r", default, skip_serializing_if = "BTreeSet::is_empty")]
20	pub refs: BTreeSet<Cid>,
21	#[serde(rename = "c")]
22	pub clock: Clock,
23}
24
25#[derive(Debug, Clone, Serialize, Deserialize, PartialEq)]
26pub struct SignedEntry {
27	/// The identity.
28	#[serde(rename = "u")]
29	pub identity: String,
30
31	/// Identity public key.
32	#[serde(rename = "k", default, with = "serde_bytes", skip_serializing_if = "Option::is_none")]
33	pub public_key: Option<Vec<u8>>,
34
35	/// The identity.
36	#[serde(rename = "s", with = "serde_bytes")]
37	pub signature: Vec<u8>,
38
39	/// Entry.
40	#[serde(rename = "e")]
41	// note: this causes serde to write unbounded maps which are indefinite length maps which are not supported in
42	// DAG-CBOR. #[serde(flatten)]
43	pub entry: Entry,
44}