refactor(ext/fs): deno_fs::FileSystem - conditional Send + Sync (#18993)

This allows for having a conditional `Send + Sync` on the file system trait for Deploy.
This commit is contained in:
David Sherret 2023-05-08 11:02:02 -04:00 committed by GitHub
parent 0aa2d7c9c1
commit df1ca4a158
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
12 changed files with 134 additions and 94 deletions

View file

@ -11,6 +11,9 @@ use deno_io::fs::File;
use deno_io::fs::FsResult;
use deno_io::fs::FsStat;
use crate::sync::MaybeSend;
use crate::sync::MaybeSync;
#[derive(Deserialize, Default, Debug, Clone, Copy)]
#[serde(rename_all = "camelCase")]
#[serde(default)]
@ -72,8 +75,11 @@ pub struct FsDirEntry {
pub is_symlink: bool,
}
#[allow(clippy::disallowed_types)]
pub type FileSystemRc = crate::sync::MaybeArc<dyn FileSystem>;
#[async_trait::async_trait(?Send)]
pub trait FileSystem: std::fmt::Debug + Send + Sync {
pub trait FileSystem: std::fmt::Debug + MaybeSend + MaybeSync {
fn cwd(&self) -> FsResult<PathBuf>;
fn tmp_dir(&self) -> FsResult<PathBuf>;
fn chdir(&self, path: &Path) -> FsResult<()>;