use std::ffi::OsString;
use std::future::Future;
use std::path::PathBuf;
use std::time::SystemTime;
use crate::{
EntryName, EntryRef, KernelConfig, RequestInfo, ResolvedPath, ResultCreate, ResultData,
ResultEmpty, ResultEntry, ResultOpen, ResultReaddir, ResultStatfs, ResultWrite, ResultXattr,
};
#[cfg(target_os = "macos")]
use crate::ResultXTimes;
pub trait AsyncFilesystem: Send + Sync + 'static {
fn init(&self, req: RequestInfo, config: &mut KernelConfig) -> ResultEmpty;
fn destroy(&self);
fn getattr(
&self,
req: RequestInfo,
path: EntryRef,
fh: Option<u64>,
) -> impl Future<Output = ResultEntry> + Send;
fn chmod(
&self,
req: RequestInfo,
path: ResolvedPath,
fh: Option<u64>,
mode: u32,
) -> impl Future<Output = ResultEmpty> + Send;
fn chown(
&self,
req: RequestInfo,
path: ResolvedPath,
fh: Option<u64>,
uid: Option<u32>,
gid: Option<u32>,
) -> impl Future<Output = ResultEmpty> + Send;
fn truncate(
&self,
req: RequestInfo,
path: ResolvedPath,
fh: Option<u64>,
size: u64,
) -> impl Future<Output = ResultEmpty> + Send;
fn utimens(
&self,
req: RequestInfo,
path: ResolvedPath,
fh: Option<u64>,
atime: Option<SystemTime>,
mtime: Option<SystemTime>,
) -> impl Future<Output = ResultEmpty> + Send;
#[allow(clippy::too_many_arguments)]
fn utimens_macos(
&self,
req: RequestInfo,
path: ResolvedPath,
fh: Option<u64>,
crtime: Option<SystemTime>,
chgtime: Option<SystemTime>,
bkuptime: Option<SystemTime>,
flags: Option<u32>,
) -> impl Future<Output = ResultEmpty> + Send;
fn readlink(
&self,
req: RequestInfo,
path: ResolvedPath,
) -> impl Future<Output = ResultData> + Send;
fn mknod(
&self,
req: RequestInfo,
entry: EntryName,
mode: u32,
rdev: u32,
) -> impl Future<Output = ResultEntry> + Send;
fn mkdir(
&self,
req: RequestInfo,
entry: EntryName,
mode: u32,
) -> impl Future<Output = ResultEntry> + Send;
fn unlink(
&self,
req: RequestInfo,
entry: EntryName,
) -> impl Future<Output = ResultEmpty> + Send;
fn rmdir(&self, req: RequestInfo, entry: EntryName)
-> impl Future<Output = ResultEmpty> + Send;
fn symlink(
&self,
req: RequestInfo,
entry: EntryName,
target: PathBuf,
) -> impl Future<Output = ResultEntry> + Send;
fn rename(
&self,
req: RequestInfo,
entry: EntryName,
new_entry: EntryName,
) -> impl Future<Output = ResultEmpty> + Send;
fn link(
&self,
req: RequestInfo,
path: ResolvedPath,
new_entry: EntryName,
) -> impl Future<Output = ResultEntry> + Send;
fn open(
&self,
req: RequestInfo,
path: ResolvedPath,
flags: u32,
) -> impl Future<Output = ResultOpen> + Send;
fn read(
&self,
req: RequestInfo,
path: ResolvedPath,
fh: u64,
offset: u64,
size: u32,
) -> impl Future<Output = ResultData> + Send;
fn write(
&self,
req: RequestInfo,
path: ResolvedPath,
fh: u64,
offset: u64,
data: Vec<u8>,
flags: u32,
) -> impl Future<Output = ResultWrite> + Send;
fn flush(
&self,
req: RequestInfo,
path: ResolvedPath,
fh: u64,
lock_owner: u64,
) -> impl Future<Output = ResultEmpty> + Send;
#[allow(clippy::too_many_arguments)]
fn release(
&self,
req: RequestInfo,
path: ResolvedPath,
fh: u64,
flags: u32,
lock_owner: u64,
flush: bool,
) -> impl Future<Output = ResultEmpty> + Send;
fn fsync(
&self,
req: RequestInfo,
path: ResolvedPath,
fh: u64,
datasync: bool,
) -> impl Future<Output = ResultEmpty> + Send;
fn opendir(
&self,
req: RequestInfo,
path: ResolvedPath,
flags: u32,
) -> impl Future<Output = ResultOpen> + Send;
fn readdir(
&self,
req: RequestInfo,
path: ResolvedPath,
fh: u64,
) -> impl Future<Output = ResultReaddir> + Send;
fn releasedir(
&self,
req: RequestInfo,
path: ResolvedPath,
fh: u64,
flags: u32,
) -> impl Future<Output = ResultEmpty> + Send;
fn fsyncdir(
&self,
req: RequestInfo,
path: ResolvedPath,
fh: u64,
datasync: bool,
) -> impl Future<Output = ResultEmpty> + Send;
fn statfs(
&self,
req: RequestInfo,
path: ResolvedPath,
) -> impl Future<Output = ResultStatfs> + Send;
#[allow(clippy::too_many_arguments)]
fn setxattr(
&self,
req: RequestInfo,
path: ResolvedPath,
name: OsString,
value: Vec<u8>,
flags: u32,
position: u32,
) -> impl Future<Output = ResultEmpty> + Send;
fn getxattr(
&self,
req: RequestInfo,
path: ResolvedPath,
name: OsString,
size: u32,
) -> impl Future<Output = ResultXattr> + Send;
fn listxattr(
&self,
req: RequestInfo,
path: ResolvedPath,
size: u32,
) -> impl Future<Output = ResultXattr> + Send;
fn removexattr(
&self,
req: RequestInfo,
path: ResolvedPath,
name: OsString,
) -> impl Future<Output = ResultEmpty> + Send;
fn access(
&self,
req: RequestInfo,
path: ResolvedPath,
mask: u32,
) -> impl Future<Output = ResultEmpty> + Send;
fn create(
&self,
req: RequestInfo,
path: ResolvedPath,
mode: u32,
flags: u32,
) -> impl Future<Output = ResultCreate> + Send;
#[cfg(target_os = "macos")]
fn setvolname(
&self,
req: RequestInfo,
name: OsString,
) -> impl Future<Output = ResultEmpty> + Send;
#[cfg(target_os = "macos")]
fn getxtimes(
&self,
req: RequestInfo,
path: ResolvedPath,
) -> impl Future<Output = ResultXTimes> + Send;
}