mirror of
https://github.com/danbulant/oxc
synced 2026-05-24 20:32:10 +00:00
chore: 🤖 impl fileSystem for Arc<T> (#1166)
1. Impl `FileSystem` for `Arc<T>` when `T` satisfies `FileSystem`, it is useful when the user wants to share the filesystem into multiple threads.
This commit is contained in:
parent
de6150a071
commit
746f37a389
1 changed files with 24 additions and 0 deletions
|
|
@ -1,6 +1,8 @@
|
|||
use std::{
|
||||
fs, io,
|
||||
ops::Deref,
|
||||
path::{Path, PathBuf},
|
||||
sync::Arc,
|
||||
};
|
||||
|
||||
/// File System abstraction used for `ResolverGeneric`.
|
||||
|
|
@ -94,3 +96,25 @@ impl FileSystem for FileSystemOs {
|
|||
dunce::canonicalize(path)
|
||||
}
|
||||
}
|
||||
|
||||
/// Impl FileSystem for Arc<T> when T satisfies FileSystem, it is useful when the user wants to share the filesystem into multiple threads.
|
||||
impl<T> FileSystem for Arc<T>
|
||||
where
|
||||
T: FileSystem,
|
||||
{
|
||||
fn read_to_string(&self, path: &Path) -> io::Result<String> {
|
||||
self.deref().read_to_string(path)
|
||||
}
|
||||
|
||||
fn metadata(&self, path: &Path) -> io::Result<FileMetadata> {
|
||||
self.deref().metadata(path)
|
||||
}
|
||||
|
||||
fn symlink_metadata(&self, path: &Path) -> io::Result<FileMetadata> {
|
||||
self.deref().symlink_metadata(path)
|
||||
}
|
||||
|
||||
fn canonicalize(&self, path: &Path) -> io::Result<PathBuf> {
|
||||
self.deref().canonicalize(path)
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in a new issue