use std::fmt; use serde::{Deserialize, Serialize}; macro_rules! string_id { ($name:ident) => { #[derive(Clone, Debug, Serialize, Deserialize, PartialEq, Eq, Hash, PartialOrd, Ord)] #[serde(transparent)] pub struct $name(pub String); impl $name { pub fn new(value: impl Into) -> Self { Self(value.into()) } pub fn as_str(&self) -> &str { &self.0 } } impl fmt::Display for $name { fn fmt(&self, formatter: &mut fmt::Formatter<'_>) -> fmt::Result { self.0.fmt(formatter) } } impl From for $name { fn from(value: String) -> Self { Self(value) } } impl From<&str> for $name { fn from(value: &str) -> Self { Self(value.into()) } } }; } string_id!(ConversationId); string_id!(RunId); string_id!(ToolRoundId); #[derive(Clone, Copy, Debug, Serialize, Deserialize, PartialEq, Eq, Hash, PartialOrd, Ord)] #[serde(transparent)] pub struct RevisionId(pub i64); impl fmt::Display for RevisionId { fn fmt(&self, formatter: &mut fmt::Formatter<'_>) -> fmt::Result { self.0.fmt(formatter) } } #[derive(Clone, Debug, Serialize, Deserialize, PartialEq, Eq)] pub struct Conversation { pub conversation_id: ConversationId, pub current_revision_id: RevisionId, pub active_run_id: Option, }