agent_service/run/
run_id.rs1use std::{fmt, str::FromStr};
4use uuid::Uuid;
5
6#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)]
8pub struct RunId(Uuid);
9
10impl RunId {
11 pub fn new() -> Self {
12 Self(Uuid::new_v4())
13 }
14
15 pub fn as_uuid(&self) -> Uuid {
16 self.0
17 }
18
19 pub fn from_uuid(value: Uuid) -> Self {
20 Self(value)
21 }
22}
23
24impl Default for RunId {
25 fn default() -> Self {
26 Self::new()
27 }
28}
29
30impl fmt::Display for RunId {
31 fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
32 self.0.fmt(f)
33 }
34}
35
36impl FromStr for RunId {
37 type Err = uuid::Error;
38
39 fn from_str(value: &str) -> Result<Self, Self::Err> {
40 Uuid::parse_str(value).map(Self)
41 }
42}