use crate::addr::RemoteEndpoint;
use crate::container::ContainerId;
#[derive(Debug, Clone, PartialEq, Eq, Hash, serde::Serialize, serde::Deserialize)]
pub enum Filesystem {
Local,
Remote(RemoteEndpoint),
Container(ContainerId),
}
impl Default for Filesystem {
fn default() -> Self {
Self::Local
}
}
impl Filesystem {
pub fn label(&self) -> String {
match self {
Self::Local => "local".to_string(),
Self::Remote(endpoint) => endpoint.to_string(),
Self::Container(id) => format!("container:{}", &id.as_str()[..12]),
}
}
pub fn is_remote(&self) -> bool {
matches!(self, Self::Remote(_))
}
pub fn endpoint(&self) -> Option<&RemoteEndpoint> {
match self {
Self::Remote(endpoint) => Some(endpoint),
_ => None,
}
}
}