use std::fmt::Display;
use std::fmt::Formatter;
#[derive(Debug, Copy, Clone, Hash, Eq, PartialEq, Default)]
#[non_exhaustive]
pub enum Operation {
#[default]
Info,
CreateDir,
Read,
Write,
Copy,
Rename,
Stat,
Delete,
List,
Presign,
}
impl Operation {
pub fn into_static(self) -> &'static str {
self.into()
}
}
impl Display for Operation {
fn fmt(&self, f: &mut Formatter<'_>) -> std::fmt::Result {
write!(f, "{}", self.into_static())
}
}
impl From<Operation> for &'static str {
fn from(v: Operation) -> &'static str {
match v {
Operation::Info => "info",
Operation::CreateDir => "create_dir",
Operation::Read => "read",
Operation::Write => "write",
Operation::Copy => "copy",
Operation::Rename => "rename",
Operation::Stat => "stat",
Operation::Delete => "delete",
Operation::List => "list",
Operation::Presign => "presign",
}
}
}
impl From<Operation> for String {
fn from(v: Operation) -> Self {
v.into_static().to_string()
}
}