Skip to main content

aether_core/events/
compaction_id.rs

1use schemars::JsonSchema;
2use serde::{Deserialize, Serialize};
3
4/// Protocol-independent identity persisted across a compaction's lifecycle.
5#[derive(Debug, Clone, PartialEq, Eq, Hash, Serialize, Deserialize, JsonSchema)]
6#[serde(transparent)]
7pub struct CompactionId(String);
8
9impl CompactionId {
10    pub fn new() -> Self {
11        Self(uuid::Uuid::new_v4().to_string())
12    }
13
14    pub fn as_str(&self) -> &str {
15        &self.0
16    }
17}
18
19impl Default for CompactionId {
20    fn default() -> Self {
21        Self::new()
22    }
23}
24
25impl From<String> for CompactionId {
26    fn from(value: String) -> Self {
27        Self(value)
28    }
29}
30
31impl From<&str> for CompactionId {
32    fn from(value: &str) -> Self {
33        Self(value.to_owned())
34    }
35}