use bon::Builder;
use url::Url;
#[derive(Clone, Debug)]
pub enum Type {
File,
Directory,
}
#[derive(Builder, Clone, Debug)]
#[builder(builder_type = Builder)]
pub struct Output {
#[builder(into)]
pub(crate) name: Option<String>,
#[builder(into)]
pub(crate) description: Option<String>,
#[builder(into)]
pub(crate) url: Url,
#[builder(into)]
pub(crate) path: String,
#[builder(into)]
pub(crate) ty: Type,
}
impl Output {
pub fn name(&self) -> Option<&str> {
self.name.as_deref()
}
pub fn description(&self) -> Option<&str> {
self.description.as_deref()
}
pub fn url(&self) -> &str {
self.url.as_ref()
}
pub fn path(&self) -> &str {
&self.path
}
pub fn ty(&self) -> &Type {
&self.ty
}
}
impl From<Output> for tes::v1::types::task::Output {
fn from(output: Output) -> Self {
let Output {
name,
description,
url,
path,
ty,
} = output;
let ty = match ty {
Type::File => tes::v1::types::task::IoType::File,
Type::Directory => tes::v1::types::task::IoType::Directory,
};
Self {
name,
description,
url: url.to_string(),
path,
path_prefix: None,
ty,
}
}
}