#[derive(Debug, Clone, PartialEq, Eq)]
pub enum StoreKind {
S3 {
bucket: String,
region: Option<String>,
endpoint: Option<String>,
profile: Option<String>,
},
Filesystem { root: String },
Sftp {
server: Box<crate::ssh_tunnel::models::SshTunnel>,
root: String,
},
}
#[derive(Debug, Clone, PartialEq, Eq)]
pub struct Location {
pub store: StoreKind,
pub prefix: String,
}
impl std::fmt::Display for Location {
fn fmt(&self, formatter: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
match &self.store {
StoreKind::S3 { bucket, .. } => write!(formatter, "s3://{bucket}/{}", self.prefix),
StoreKind::Filesystem { root } => {
write!(formatter, "{}/{}", root.trim_end_matches('/'), self.prefix)
}
StoreKind::Sftp { server, root } => match root.as_str() {
"/" => write!(formatter, "sftp://{}/{}", server.host, self.prefix),
_ => write!(
formatter,
"sftp://{}@{}/~/{}",
server.user, server.host, self.prefix
),
},
}
}
}