use std::{ops::Deref, path::PathBuf}; #[derive(Clone, Debug)] pub struct CommitArtifact { pub app: String, pub branch: String, pub upload_id: UploadArtifactID, } #[derive(Clone, Debug)] pub struct Release { pub app: String, pub branch: String, } #[derive(Debug, Clone)] pub struct ArtifactID(uuid::Uuid); impl ArtifactID { pub fn new() -> Self { Self(uuid::Uuid::now_v7()) } } impl std::ops::Deref for ArtifactID { type Target = uuid::Uuid; fn deref(&self) -> &Self::Target { &self.0 } } impl TryFrom for ArtifactID { type Error = anyhow::Error; fn try_from(value: String) -> Result { let uuid = uuid::Uuid::parse_str(&value)?; Ok(ArtifactID(uuid)) } } impl From for ArtifactID { fn from(value: uuid::Uuid) -> Self { Self(value) } } pub struct UploadArtifact { pub file_path: PathBuf, } impl From for UploadArtifact { fn from(value: PathBuf) -> Self { Self { file_path: value } } } #[derive(Clone, Debug)] pub struct UploadArtifactID(uuid::Uuid); impl From for UploadArtifactID { fn from(value: uuid::Uuid) -> Self { Self(value) } } impl From for uuid::Uuid { fn from(value: ArtifactID) -> Self { value.0 } } impl TryFrom for UploadArtifactID { type Error = anyhow::Error; fn try_from(value: String) -> Result { let uuid = uuid::Uuid::parse_str(&value)?; Ok(Self(uuid)) } } impl Deref for UploadArtifactID { type Target = uuid::Uuid; fn deref(&self) -> &Self::Target { &self.0 } }