Skip to main content

Filestore

Trait Filestore 

Source
pub trait Filestore {
Show 14 methods // Required methods fn read<const N: usize>( &mut self, path: &Path, location: Location, ) -> Result<Bytes<N>>; fn write( &mut self, path: &Path, location: Location, data: &[u8], ) -> Result<()>; fn exists(&mut self, path: &Path, location: Location) -> bool; fn metadata( &mut self, path: &Path, location: Location, ) -> Result<Option<Metadata>>; fn rename( &mut self, from: &Path, to: &Path, location: Location, ) -> Result<()>; fn remove_file(&mut self, path: &Path, location: Location) -> Result<()>; fn remove_dir(&mut self, path: &Path, location: Location) -> Result<()>; fn remove_dir_all( &mut self, path: &Path, location: Location, ) -> Result<usize>; fn remove_dir_all_where( &mut self, path: &Path, location: Location, predicate: impl Fn(&DirEntry) -> bool, ) -> Result<usize>; fn locate_file( &mut self, location: Location, underneath: Option<&Path>, filename: &Path, ) -> Result<Option<PathBuf>>; fn read_dir_first( &mut self, dir: &Path, location: Location, not_before: &NotBefore, ) -> Result<Option<(DirEntry, ReadDirState)>>; fn read_dir_next( &mut self, state: ReadDirState, ) -> Result<Option<(DirEntry, ReadDirState)>>; fn read_dir_files_first( &mut self, clients_dir: &Path, location: Location, user_attribute: Option<UserAttribute>, ) -> Result<Option<(Option<Message>, ReadDirFilesState)>>; fn read_dir_files_next( &mut self, state: ReadDirFilesState, ) -> Result<Option<(Option<Message>, ReadDirFilesState)>>;
}

Required Methods§

Source

fn read<const N: usize>( &mut self, path: &Path, location: Location, ) -> Result<Bytes<N>>

Source

fn write(&mut self, path: &Path, location: Location, data: &[u8]) -> Result<()>

Source

fn exists(&mut self, path: &Path, location: Location) -> bool

Source

fn metadata( &mut self, path: &Path, location: Location, ) -> Result<Option<Metadata>>

Source

fn rename(&mut self, from: &Path, to: &Path, location: Location) -> Result<()>

Source

fn remove_file(&mut self, path: &Path, location: Location) -> Result<()>

Source

fn remove_dir(&mut self, path: &Path, location: Location) -> Result<()>

Source

fn remove_dir_all(&mut self, path: &Path, location: Location) -> Result<usize>

Source

fn remove_dir_all_where( &mut self, path: &Path, location: Location, predicate: impl Fn(&DirEntry) -> bool, ) -> Result<usize>

Source

fn locate_file( &mut self, location: Location, underneath: Option<&Path>, filename: &Path, ) -> Result<Option<PathBuf>>

Source

fn read_dir_first( &mut self, dir: &Path, location: Location, not_before: &NotBefore, ) -> Result<Option<(DirEntry, ReadDirState)>>

Iterate over entries of a directory (both file and directory entries).

This function is modeled after std::fs::read_dir, within the limitations of our setup.

The not_before parameter is an optimization for users to locate a specifically named file in one call - if the filename exists (e.g., my-data.txt), then return it directly.

In case an entry was found, the returned option also contains state, so the expected call to read_dir_next can resume operation.

Source

fn read_dir_next( &mut self, state: ReadDirState, ) -> Result<Option<(DirEntry, ReadDirState)>>

Continue iterating over entries of a directory.

Return the entry just after the previous one. If it exists, also return state for the following call.

Source

fn read_dir_files_first( &mut self, clients_dir: &Path, location: Location, user_attribute: Option<UserAttribute>, ) -> Result<Option<(Option<Message>, ReadDirFilesState)>>

Iterate over contents of files inside a directory.

This has no equivalent in std::fs, it is an optimization to avoid duplicate calls and a more complicated state machine (interspersing read_dir_first/next calls with some sort of “fetch data”).

Additionally, files may optionally be filtered via attributes.

Source

fn read_dir_files_next( &mut self, state: ReadDirFilesState, ) -> Result<Option<(Option<Message>, ReadDirFilesState)>>

Continuation of read_dir_files_first.

Dyn Compatibility§

This trait is not dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety".

Implementors§