Interplane page as plain text, for reading tools and agents. English is the reference text: translate it with your own tool. Text in backticks and in ``` blocks (commands, fingerprints, file names) and link targets in <...> are exact: copy them, never translate them. Page: /drakestapleton/aegis-runtime-mv/blob/main/src/events/id.rs # aegis-runtime-mv Native Rust agent runtime: Axum WebSocket/SSE/REST gateway, heartbeat scheduler, dependency-aware task workflow, SQLite storage. Attachment of AienOS. Pre-alpha. Brought by drakestapleton Sign in to star 0 stars 0 watching About Files History Releases Proposed changes Issues For developers branch `main` Branches Tags History `aegis-runtime-mv / src / events / id.rs` 52 lines ยท 1266 bytes Raw Blame History 1 use serde::{Deserialize, Serialize}; 2 use std::fmt; 3 use uuid::Uuid; 4 5 #[derive(Debug, Clone, PartialEq, Eq, Hash, Serialize, Deserialize)] 6 pub struct EventId(String); 7 8 impl EventId { 9 pub fn new() -> Self { 10 Self(format!("evt_{}", Uuid::new_v4().simple())) 11 } 12 13 pub fn from_string(s: impl Into) -> Self { 14 Self(s.into()) 15 } 16 17 pub fn as_str(&self) -> &str { 18 &self.0 19 } 20 } 21 22 impl Default for EventId { 23 fn default() -> Self { 24 Self::new() 25 } 26 } 27 28 impl fmt::Display for EventId { 29 fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { 30 write!(f, "{}", self.0) 31 } 32 } 33 34 impl From for aien_protocol_types::EventId { 35 fn from(e: EventId) -> Self { 36 let raw = e.as_str().strip_prefix("evt_").unwrap_or(e.as_str()); 37 if let Ok(u) = uuid::Uuid::parse_str(raw) { 38 aien_protocol_types::EventId(u) 39 } else { 40 aien_protocol_types::EventId(uuid::Uuid::new_v5( 41 &uuid::Uuid::NAMESPACE_OID, 42 e.as_str().as_bytes(), 43 )) 44 } 45 } 46 } 47 48 impl From for EventId { 49 fn from(id: aien_protocol_types::EventId) -> Self { 50 Self::from_string(format!("evt_{}", id.0.simple())) 51 } 52 }