1use super::{ClientResult, PollClient};
2use crate::{
3 api::{reply, request},
4 types::{Location, Message, NotBefore, PathBuf, UserAttribute},
5};
6
7pub trait FilesystemClient: PollClient {
9 fn debug_dump_store(&mut self) -> ClientResult<'_, reply::DebugDumpStore, Self> {
10 self.request(request::DebugDumpStore {})
11 }
12
13 fn read_dir_first(
17 &mut self,
18 location: Location,
19 dir: PathBuf,
20 not_before_filename: Option<PathBuf>,
21 ) -> ClientResult<'_, reply::ReadDirFirst, Self> {
22 self.request(request::ReadDirFirst {
23 location,
24 dir,
25 not_before: NotBefore::with_filename(not_before_filename),
26 })
27 }
28
29 fn read_dir_first_alphabetical(
37 &mut self,
38 location: Location,
39 dir: PathBuf,
40 not_before_filename: Option<PathBuf>,
41 ) -> ClientResult<'_, reply::ReadDirFirst, Self> {
42 self.request(request::ReadDirFirst {
43 location,
44 dir,
45 not_before: NotBefore::with_filename_part(not_before_filename),
46 })
47 }
48
49 fn read_dir_next(&mut self) -> ClientResult<'_, reply::ReadDirNext, Self> {
50 self.request(request::ReadDirNext {})
51 }
52
53 fn read_dir_files_first(
54 &mut self,
55 location: Location,
56 dir: PathBuf,
57 user_attribute: Option<UserAttribute>,
58 ) -> ClientResult<'_, reply::ReadDirFilesFirst, Self> {
59 self.request(request::ReadDirFilesFirst {
60 dir,
61 location,
62 user_attribute,
63 })
64 }
65
66 fn read_dir_files_next(&mut self) -> ClientResult<'_, reply::ReadDirFilesNext, Self> {
67 self.request(request::ReadDirFilesNext {})
68 }
69
70 fn remove_dir(
71 &mut self,
72 location: Location,
73 path: PathBuf,
74 ) -> ClientResult<'_, reply::RemoveDir, Self> {
75 self.request(request::RemoveDir { location, path })
76 }
77
78 fn remove_dir_all(
79 &mut self,
80 location: Location,
81 path: PathBuf,
82 ) -> ClientResult<'_, reply::RemoveDirAll, Self> {
83 self.request(request::RemoveDirAll { location, path })
84 }
85
86 fn remove_file(
87 &mut self,
88 location: Location,
89 path: PathBuf,
90 ) -> ClientResult<'_, reply::RemoveFile, Self> {
91 self.request(request::RemoveFile { location, path })
92 }
93
94 fn read_file(
95 &mut self,
96 location: Location,
97 path: PathBuf,
98 ) -> ClientResult<'_, reply::ReadFile, Self> {
99 self.request(request::ReadFile { location, path })
100 }
101
102 fn entry_metadata(
106 &mut self,
107 location: Location,
108 path: PathBuf,
109 ) -> ClientResult<'_, reply::Metadata, Self> {
110 self.request(request::Metadata { location, path })
111 }
112
113 fn rename(
118 &mut self,
119 location: Location,
120 from: PathBuf,
121 to: PathBuf,
122 ) -> ClientResult<'_, reply::Rename, Self> {
123 self.request(request::Rename { location, from, to })
124 }
125
126 fn locate_file(
127 &mut self,
128 location: Location,
129 dir: Option<PathBuf>,
130 filename: PathBuf,
131 ) -> ClientResult<'_, reply::LocateFile, Self> {
132 self.request(request::LocateFile {
133 location,
134 dir,
135 filename,
136 })
137 }
138
139 fn write_file(
140 &mut self,
141 location: Location,
142 path: PathBuf,
143 data: Message,
144 user_attribute: Option<UserAttribute>,
145 ) -> ClientResult<'_, reply::WriteFile, Self> {
146 self.request(request::WriteFile {
147 location,
148 path,
149 data,
150 user_attribute,
151 })
152 }
153}