moirai_async/fs/
options.rs1#[derive(Debug, Clone)]
3pub struct FileOpenOptions {
4 pub read: bool,
6 pub write: bool,
8 pub create: bool,
10 pub append: bool,
12 pub truncate: bool,
14}
15
16impl Default for FileOpenOptions {
17 fn default() -> Self {
18 Self {
19 read: true,
20 write: false,
21 create: false,
22 append: false,
23 truncate: false,
24 }
25 }
26}
27
28impl FileOpenOptions {
29 pub fn read_only() -> Self {
31 Self {
32 read: true,
33 write: false,
34 create: false,
35 append: false,
36 truncate: false,
37 }
38 }
39
40 pub fn write_only() -> Self {
42 Self {
43 read: false,
44 write: true,
45 create: true,
46 append: false,
47 truncate: true,
48 }
49 }
50
51 pub fn append_only() -> Self {
53 Self {
54 read: false,
55 write: true,
56 create: true,
57 append: true,
58 truncate: false,
59 }
60 }
61
62 pub fn read_write() -> Self {
64 Self {
65 read: true,
66 write: true,
67 create: true,
68 append: false,
69 truncate: false,
70 }
71 }
72}