1use std::{path::Path, sync::Arc};
6
7use crate::*;
8
9#[derive(Debug)]
10pub struct ArcFileSystem {
11 fs: Arc<dyn FileSystem + Send + Sync + 'static>,
12}
13
14impl ArcFileSystem {
15 pub fn new(inner: Arc<dyn FileSystem + Send + Sync + 'static>) -> Self {
16 Self { fs: inner }
17 }
18}
19
20impl FileSystem for ArcFileSystem {
21 fn readlink(&self, path: &Path) -> Result<PathBuf> {
22 self.fs.readlink(path)
23 }
24
25 fn read_dir(&self, path: &Path) -> Result<ReadDir> {
26 self.fs.read_dir(path)
27 }
28
29 fn create_dir(&self, path: &Path) -> Result<()> {
30 self.fs.create_dir(path)
31 }
32
33 fn remove_dir(&self, path: &Path) -> Result<()> {
34 self.fs.remove_dir(path)
35 }
36
37 fn rename<'a>(&'a self, from: &'a Path, to: &'a Path) -> BoxFuture<'a, Result<()>> {
38 Box::pin(async { self.fs.rename(from, to).await })
39 }
40
41 fn metadata(&self, path: &Path) -> Result<Metadata> {
42 self.fs.metadata(path)
43 }
44
45 fn symlink_metadata(&self, path: &Path) -> Result<Metadata> {
46 self.fs.symlink_metadata(path)
47 }
48
49 fn remove_file(&self, path: &Path) -> Result<()> {
50 self.fs.remove_file(path)
51 }
52
53 fn new_open_options(&self) -> OpenOptions<'_> {
54 self.fs.new_open_options()
55 }
56
57 fn mount(
58 &self,
59 name: String,
60 path: &Path,
61 fs: Box<dyn crate::FileSystem + Send + Sync>,
62 ) -> Result<()> {
63 self.fs.mount(name, path, fs)
64 }
65}