Skip to main content

fslite_sqlite/
backend.rs

1//! `fslite_core::FileSystem` trait implementation for [`SqliteFileSystem`].
2//!
3//! Each method delegates to the identically named inherent method on
4//! [`SqliteFileSystem`] where one exists (Rust resolves `self.<name>(..)`
5//! calls below to the inherent method, not back into this trait impl).
6//! Adding a new trait method? Add the inherent method on `SqliteFileSystem`
7//! in `lib.rs` first; this file's delegate is then a one-line `match` arm.
8
9use async_trait::async_trait;
10use fslite_core::{
11    BatchOperation, BatchResult, Change, ChangeCursor, ContentQuery, CopyOptions, CreateOptions,
12    FileRead, FileSystem, FindQuery, FsResult, LinkTarget, MoveOptions, MutationOptions, Node,
13    Page, PageRequest, ReadOptions, RemoveOptions, RequestContext, SearchMatch, StatOptions,
14    TouchOptions, TrashEntry, TrashId, TreeEntry, TreeOptions, VirtualPath, WorkspaceUsage,
15    WriteOptions, WriteSource,
16};
17
18use crate::SqliteFileSystem;
19
20#[async_trait]
21impl FileSystem for SqliteFileSystem {
22    async fn workspace_usage(&self, ctx: &RequestContext) -> FsResult<WorkspaceUsage> {
23        self.workspace_usage(ctx).await
24    }
25
26    async fn stat(
27        &self,
28        ctx: &RequestContext,
29        path: &VirtualPath,
30        options: StatOptions,
31    ) -> FsResult<Node> {
32        self.stat(ctx, path, options).await
33    }
34
35    async fn exists(
36        &self,
37        ctx: &RequestContext,
38        path: &VirtualPath,
39        options: StatOptions,
40    ) -> FsResult<bool> {
41        self.exists(ctx, path, options).await
42    }
43
44    async fn read_dir(
45        &self,
46        ctx: &RequestContext,
47        path: &VirtualPath,
48        page: PageRequest,
49    ) -> FsResult<Page<Node>> {
50        self.read_dir(ctx, path, page).await
51    }
52
53    async fn tree(
54        &self,
55        ctx: &RequestContext,
56        path: &VirtualPath,
57        options: TreeOptions,
58        page: PageRequest,
59    ) -> FsResult<Page<TreeEntry>> {
60        self.tree(ctx, path, options, page).await
61    }
62
63    async fn mkdir(
64        &self,
65        ctx: &RequestContext,
66        path: &VirtualPath,
67        options: CreateOptions,
68    ) -> FsResult<Node> {
69        self.mkdir(ctx, path, options).await
70    }
71
72    async fn read(
73        &self,
74        ctx: &RequestContext,
75        path: &VirtualPath,
76        options: ReadOptions,
77    ) -> FsResult<FileRead> {
78        self.read(ctx, path, options).await
79    }
80
81    async fn write(
82        &self,
83        ctx: &RequestContext,
84        path: &VirtualPath,
85        source: WriteSource,
86        options: WriteOptions,
87    ) -> FsResult<Node> {
88        self.write(ctx, path, source, options).await
89    }
90
91    async fn write_at(
92        &self,
93        ctx: &RequestContext,
94        path: &VirtualPath,
95        offset: u64,
96        source: WriteSource,
97        options: WriteOptions,
98    ) -> FsResult<Node> {
99        self.write_at(ctx, path, offset, source, options).await
100    }
101
102    async fn append(
103        &self,
104        ctx: &RequestContext,
105        path: &VirtualPath,
106        source: WriteSource,
107        options: WriteOptions,
108    ) -> FsResult<Node> {
109        self.append(ctx, path, source, options).await
110    }
111
112    async fn truncate(
113        &self,
114        ctx: &RequestContext,
115        path: &VirtualPath,
116        length: u64,
117        options: MutationOptions,
118    ) -> FsResult<Node> {
119        self.truncate(ctx, path, length, options).await
120    }
121
122    async fn touch(
123        &self,
124        ctx: &RequestContext,
125        path: &VirtualPath,
126        options: TouchOptions,
127    ) -> FsResult<Node> {
128        self.touch(ctx, path, options).await
129    }
130
131    async fn copy(
132        &self,
133        ctx: &RequestContext,
134        from: &VirtualPath,
135        to: &VirtualPath,
136        options: CopyOptions,
137    ) -> FsResult<Node> {
138        self.copy(ctx, from, to, options).await
139    }
140
141    async fn move_path(
142        &self,
143        ctx: &RequestContext,
144        from: &VirtualPath,
145        to: &VirtualPath,
146        options: MoveOptions,
147    ) -> FsResult<Node> {
148        self.move_path(ctx, from, to, options).await
149    }
150
151    async fn remove(
152        &self,
153        ctx: &RequestContext,
154        path: &VirtualPath,
155        options: RemoveOptions,
156    ) -> FsResult<()> {
157        self.remove(ctx, path, options).await
158    }
159
160    async fn symlink(
161        &self,
162        ctx: &RequestContext,
163        target: &LinkTarget,
164        link: &VirtualPath,
165        options: CreateOptions,
166    ) -> FsResult<Node> {
167        self.symlink(ctx, target, link, options).await
168    }
169
170    async fn read_link(&self, ctx: &RequestContext, path: &VirtualPath) -> FsResult<LinkTarget> {
171        self.read_link(ctx, path).await
172    }
173
174    async fn trash(
175        &self,
176        ctx: &RequestContext,
177        path: &VirtualPath,
178        options: MutationOptions,
179    ) -> FsResult<TrashEntry> {
180        self.trash(ctx, path, options).await
181    }
182
183    async fn list_trash(
184        &self,
185        ctx: &RequestContext,
186        page: PageRequest,
187    ) -> FsResult<Page<TrashEntry>> {
188        self.list_trash(ctx, page).await
189    }
190
191    async fn restore(
192        &self,
193        ctx: &RequestContext,
194        trash: TrashId,
195        destination: Option<&VirtualPath>,
196        options: MutationOptions,
197    ) -> FsResult<Node> {
198        self.restore(ctx, trash, destination, options).await
199    }
200
201    async fn purge(&self, ctx: &RequestContext, trash: TrashId) -> FsResult<()> {
202        self.purge(ctx, trash).await
203    }
204
205    async fn set_attribute(
206        &self,
207        ctx: &RequestContext,
208        path: &VirtualPath,
209        key: &str,
210        value: &[u8],
211        options: MutationOptions,
212    ) -> FsResult<Node> {
213        self.set_attribute(ctx, path, key, value, options).await
214    }
215
216    async fn remove_attribute(
217        &self,
218        ctx: &RequestContext,
219        path: &VirtualPath,
220        key: &str,
221        options: MutationOptions,
222    ) -> FsResult<Node> {
223        self.remove_attribute(ctx, path, key, options).await
224    }
225
226    async fn glob(
227        &self,
228        ctx: &RequestContext,
229        pattern: &str,
230        page: PageRequest,
231    ) -> FsResult<Page<Node>> {
232        self.glob(ctx, pattern, page).await
233    }
234
235    async fn find(
236        &self,
237        ctx: &RequestContext,
238        query: FindQuery,
239        page: PageRequest,
240    ) -> FsResult<Page<Node>> {
241        self.find(ctx, query, page).await
242    }
243
244    async fn search_content(
245        &self,
246        ctx: &RequestContext,
247        query: ContentQuery,
248        page: PageRequest,
249    ) -> FsResult<Page<SearchMatch>> {
250        self.search_content(ctx, query, page).await
251    }
252
253    async fn batch(
254        &self,
255        ctx: &RequestContext,
256        operations: Vec<BatchOperation>,
257    ) -> FsResult<Vec<BatchResult>> {
258        self.batch(ctx, operations).await
259    }
260
261    async fn changes(
262        &self,
263        ctx: &RequestContext,
264        after: Option<ChangeCursor>,
265        page: PageRequest,
266    ) -> FsResult<Page<Change>> {
267        self.changes(ctx, after, page).await
268    }
269}