Skip to main content

file_storage/error/
operation.rs

1use std::fmt::{Display, Formatter};
2
3/// A path operation.
4#[derive(Copy, Clone, Ord, PartialOrd, Eq, PartialEq, Hash, Debug)]
5#[non_exhaustive]
6pub enum Operation {
7    /// Check if a file exists.
8    Exists,
9
10    /// Read a file.
11    Read,
12
13    /// Write a file.
14    Write,
15
16    /// Delete a file.
17    Delete,
18
19    /// List the files in a folder.
20    ListFiles,
21
22    /// Delete the files in a folder.
23    DeleteFiles,
24
25    /// Modify a path.
26    ModifyPath,
27}
28
29impl Display for Operation {
30    fn fmt(&self, f: &mut Formatter<'_>) -> std::fmt::Result {
31        let s: &str = match self {
32            Operation::Exists => "exists",
33            Operation::Read => "read",
34            Operation::Write => "write",
35            Operation::Delete => "delete",
36            Operation::ListFiles => "list-files",
37            Operation::DeleteFiles => "delete-files",
38            Operation::ModifyPath => "modify-path",
39        };
40        f.write_str(s)
41    }
42}