Skip to main content

causa_kernel/context/
ids.rs

1use serde::{Deserialize, Serialize};
2use uuid::Uuid;
3
4/// Identity of an execution, independent of its context material.
5///
6/// Serializable for logs and tests; the serialized form is not part of the
7/// stable set and may change in any release.
8#[derive(Debug, Clone, PartialEq, Eq, Hash, Serialize, Deserialize)]
9pub struct TurnId(pub String);
10impl TurnId {
11    /// Wraps an arbitrary string as a turn id.
12    pub fn new(s: impl Into<String>) -> Self {
13        Self(s.into())
14    }
15}
16
17/// Ordinal of a model round within a turn (0-based).
18///
19/// Serializable for logs and tests; the serialized form is not part of the
20/// stable set and may change in any release.
21#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash, Serialize, Deserialize)]
22pub struct RoundId(pub u32);
23
24/// Identity of one model invocation: which turn, and which round inside it.
25///
26/// Serializable for logs and tests; the serialized form is not part of the
27/// stable set and may change in any release.
28#[derive(Debug, Clone, PartialEq, Eq, Hash, Serialize, Deserialize)]
29pub struct InvocationId {
30    /// The turn the invocation belongs to.
31    pub turn_id: TurnId,
32    /// The round within the turn.
33    pub round_id: RoundId,
34}
35
36/// UUID identity of one fact block, independent of its current position.
37#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash, Serialize, Deserialize)]
38#[serde(transparent)]
39pub struct BlockId(pub Uuid);
40impl BlockId {
41    /// Wraps a UUID supplied by the caller.
42    pub const fn new(uuid: Uuid) -> Self {
43        Self(uuid)
44    }
45}