Skip to main content

bobby_browser_client/
ids.rs

1//! Typed UUID newtypes used across the `/v1` wire contract.
2
3use serde::{Deserialize, Serialize};
4use uuid::Uuid;
5
6macro_rules! uuid_id {
7    ($name:ident) => {
8        #[derive(Debug, Clone, Serialize, Deserialize, PartialEq, Eq, Hash)]
9        #[cfg_attr(feature = "schema", derive(schemars::JsonSchema))]
10        #[serde(transparent)]
11        pub struct $name(pub Uuid);
12
13        impl $name {
14            pub fn new() -> Self {
15                Self(Uuid::new_v4())
16            }
17        }
18
19        impl Default for $name {
20            fn default() -> Self {
21                Self::new()
22            }
23        }
24    };
25}
26
27uuid_id!(SessionId);
28uuid_id!(PageId);
29uuid_id!(CommandId);
30uuid_id!(WorkflowId);
31uuid_id!(AttemptId);
32uuid_id!(EvidenceId);
33uuid_id!(WorkerId);
34uuid_id!(JobId);
35uuid_id!(ArtifactId);
36uuid_id!(CheckpointId);
37uuid_id!(CompanionId);
38uuid_id!(ProfileId);
39uuid_id!(AttachmentId);