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 pub fn inner(&self) -> &Arc<dyn FileSystem + Send + Sync + 'static> {
20 &self.fs
21 }
22}
23
24impl FileSystem for ArcFileSystem {
25 fn readlink(&self, path: &Path) -> Result<PathBuf> {
26 self.fs.readlink(path)
27 }
28
29 fn read_dir(&self, path: &Path) -> Result<ReadDir> {
30 self.fs.read_dir(path)
31 }
32
33 fn create_dir(&self, path: &Path) -> Result<()> {
34 self.fs.create_dir(path)
35 }
36
37 fn create_symlink(&self, source: &Path, target: &Path) -> Result<()> {
38 self.fs.create_symlink(source, target)
39 }
40
41 fn remove_dir(&self, path: &Path) -> Result<()> {
42 self.fs.remove_dir(path)
43 }
44
45 fn rename<'a>(&'a self, from: &'a Path, to: &'a Path) -> BoxFuture<'a, Result<()>> {
46 Box::pin(async { self.fs.rename(from, to).await })
47 }
48
49 fn metadata(&self, path: &Path) -> Result<Metadata> {
50 self.fs.metadata(path)
51 }
52
53 fn symlink_metadata(&self, path: &Path) -> Result<Metadata> {
54 self.fs.symlink_metadata(path)
55 }
56
57 fn remove_file(&self, path: &Path) -> Result<()> {
58 self.fs.remove_file(path)
59 }
60
61 fn new_open_options(&self) -> OpenOptions<'_> {
62 self.fs.new_open_options()
63 }
64}