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#[derive(Debug, Clone, PartialEq, Eq, Hash, Serialize, Deserialize)]
6pub struct TurnId(pub String);
7impl TurnId {
8    /// Wraps an arbitrary string as a turn id.
9    pub fn new(s: impl Into<String>) -> Self {
10        Self(s.into())
11    }
12}
13
14/// Ordinal of a model round within a turn (0-based).
15#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash, Serialize, Deserialize)]
16pub struct RoundId(pub u32);
17
18/// Identity of one model invocation: which turn, and which round inside it.
19#[derive(Debug, Clone, PartialEq, Eq, Hash, Serialize, Deserialize)]
20pub struct InvocationId {
21    /// The turn the invocation belongs to.
22    pub turn_id: TurnId,
23    /// The round within the turn.
24    pub round_id: RoundId,
25}
26
27/// UUID identity of one fact block, independent of its current position.
28#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash, Serialize, Deserialize)]
29#[serde(transparent)]
30pub struct BlockId(pub Uuid);
31impl BlockId {
32    /// Wraps a UUID supplied by the caller.
33    pub const fn new(uuid: Uuid) -> Self {
34        Self(uuid)
35    }
36}