use super::{ClientResult, PollClient};
use crate::{
api::{reply, request},
types::{Location, Message, NotBefore, PathBuf, UserAttribute},
};
pub trait FilesystemClient: PollClient {
fn debug_dump_store(&mut self) -> ClientResult<'_, reply::DebugDumpStore, Self> {
self.request(request::DebugDumpStore {})
}
fn read_dir_first(
&mut self,
location: Location,
dir: PathBuf,
not_before_filename: Option<PathBuf>,
) -> ClientResult<'_, reply::ReadDirFirst, Self> {
self.request(request::ReadDirFirst {
location,
dir,
not_before: NotBefore::with_filename(not_before_filename),
})
}
fn read_dir_first_alphabetical(
&mut self,
location: Location,
dir: PathBuf,
not_before_filename: Option<PathBuf>,
) -> ClientResult<'_, reply::ReadDirFirst, Self> {
self.request(request::ReadDirFirst {
location,
dir,
not_before: NotBefore::with_filename_part(not_before_filename),
})
}
fn read_dir_next(&mut self) -> ClientResult<'_, reply::ReadDirNext, Self> {
self.request(request::ReadDirNext {})
}
fn read_dir_files_first(
&mut self,
location: Location,
dir: PathBuf,
user_attribute: Option<UserAttribute>,
) -> ClientResult<'_, reply::ReadDirFilesFirst, Self> {
self.request(request::ReadDirFilesFirst {
dir,
location,
user_attribute,
})
}
fn read_dir_files_next(&mut self) -> ClientResult<'_, reply::ReadDirFilesNext, Self> {
self.request(request::ReadDirFilesNext {})
}
fn remove_dir(
&mut self,
location: Location,
path: PathBuf,
) -> ClientResult<'_, reply::RemoveDir, Self> {
self.request(request::RemoveDir { location, path })
}
fn remove_dir_all(
&mut self,
location: Location,
path: PathBuf,
) -> ClientResult<'_, reply::RemoveDirAll, Self> {
self.request(request::RemoveDirAll { location, path })
}
fn remove_file(
&mut self,
location: Location,
path: PathBuf,
) -> ClientResult<'_, reply::RemoveFile, Self> {
self.request(request::RemoveFile { location, path })
}
fn read_file(
&mut self,
location: Location,
path: PathBuf,
) -> ClientResult<'_, reply::ReadFile, Self> {
self.request(request::ReadFile { location, path })
}
fn entry_metadata(
&mut self,
location: Location,
path: PathBuf,
) -> ClientResult<'_, reply::Metadata, Self> {
self.request(request::Metadata { location, path })
}
fn rename(
&mut self,
location: Location,
from: PathBuf,
to: PathBuf,
) -> ClientResult<'_, reply::Rename, Self> {
self.request(request::Rename { location, from, to })
}
fn locate_file(
&mut self,
location: Location,
dir: Option<PathBuf>,
filename: PathBuf,
) -> ClientResult<'_, reply::LocateFile, Self> {
self.request(request::LocateFile {
location,
dir,
filename,
})
}
fn write_file(
&mut self,
location: Location,
path: PathBuf,
data: Message,
user_attribute: Option<UserAttribute>,
) -> ClientResult<'_, reply::WriteFile, Self> {
self.request(request::WriteFile {
location,
path,
data,
user_attribute,
})
}
}