Some checks failed
continuous-integration/drone/push Build is failing
Signed-off-by: kjuulh <contact@kjuulh.io>
90 lines
1.7 KiB
Rust
90 lines
1.7 KiB
Rust
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<String> for ArtifactID {
|
|
type Error = anyhow::Error;
|
|
|
|
fn try_from(value: String) -> Result<Self, Self::Error> {
|
|
let uuid = uuid::Uuid::parse_str(&value)?;
|
|
|
|
Ok(ArtifactID(uuid))
|
|
}
|
|
}
|
|
|
|
impl From<uuid::Uuid> for ArtifactID {
|
|
fn from(value: uuid::Uuid) -> Self {
|
|
Self(value)
|
|
}
|
|
}
|
|
|
|
pub struct UploadArtifact {
|
|
pub file_path: PathBuf,
|
|
}
|
|
|
|
impl From<PathBuf> for UploadArtifact {
|
|
fn from(value: PathBuf) -> Self {
|
|
Self { file_path: value }
|
|
}
|
|
}
|
|
|
|
#[derive(Clone, Debug)]
|
|
pub struct UploadArtifactID(uuid::Uuid);
|
|
impl From<uuid::Uuid> for UploadArtifactID {
|
|
fn from(value: uuid::Uuid) -> Self {
|
|
Self(value)
|
|
}
|
|
}
|
|
|
|
impl From<ArtifactID> for uuid::Uuid {
|
|
fn from(value: ArtifactID) -> Self {
|
|
value.0
|
|
}
|
|
}
|
|
|
|
impl TryFrom<String> for UploadArtifactID {
|
|
type Error = anyhow::Error;
|
|
|
|
fn try_from(value: String) -> Result<Self, Self::Error> {
|
|
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
|
|
}
|
|
}
|