pub struct FsClient<F> { /* private fields */ }Expand description
Cloneable owner of one synchronous backend connection.
Implementations§
Source§impl<F> FsClient<F>
impl<F> FsClient<F>
pub fn new(filesystem: F) -> Self
pub fn into_inner(self) -> Result<F, Self>
Source§impl<F: FileSystem> FsClient<F>
impl<F: FileSystem> FsClient<F>
pub fn open_with(&self, request: OpenRequest) -> VfResult<FsFile<F>>
pub fn open_options(&self) -> OpenOptions<'_, F>
pub fn create(&self, path: impl AsRef<Path>) -> VfResult<FsFile<F>>
pub fn read(&self, path: impl AsRef<Path>) -> VfResult<Vec<u8>>
Sourcepub fn read_with_limit(
&self,
path: impl AsRef<Path>,
max_bytes: usize,
) -> VfResult<Vec<u8>>
pub fn read_with_limit( &self, path: impl AsRef<Path>, max_bytes: usize, ) -> VfResult<Vec<u8>>
Read one complete file while limiting the returned allocation.
Use FsFile::read_native or std::io::Read to stream files that
should not be held in one allocation.
pub fn read_to_string(&self, path: impl AsRef<Path>) -> VfResult<String>
Sourcepub fn read_to_string_with_limit(
&self,
path: impl AsRef<Path>,
max_bytes: usize,
) -> VfResult<String>
pub fn read_to_string_with_limit( &self, path: impl AsRef<Path>, max_bytes: usize, ) -> VfResult<String>
Read one complete UTF-8 file with a caller-selected allocation limit.
pub fn write(&self, path: impl AsRef<Path>, data: &[u8]) -> VfResult<()>
Source§impl<F: FileSystem> FsClient<F>
impl<F: FileSystem> FsClient<F>
Sourcepub fn read_stream(
&self,
path: impl AsRef<Path>,
callback: impl FnMut(u64, &[u8]) -> VfResult<bool>,
) -> VfResult<()>
pub fn read_stream( &self, path: impl AsRef<Path>, callback: impl FnMut(u64, &[u8]) -> VfResult<bool>, ) -> VfResult<()>
Stream one file from offset zero in bounded chunks.
The callback runs without holding the backend lock, so it may use this
client or drop other files owned by it. Return Ok(false) to stop
successfully. Callback errors
are propagated. The file is closed on success, cancellation, callback
error, or read error. At most one requested chunk is buffered at once.
Source§impl<F: MetadataFileSystem> FsClient<F>
impl<F: MetadataFileSystem> FsClient<F>
Source§impl<F: DirectoryFileSystem> FsClient<F>
impl<F: DirectoryFileSystem> FsClient<F>
pub fn create_dir(&self, path: impl AsRef<Path>) -> VfResult<()>
pub fn create_dir_with_mode( &self, path: impl AsRef<Path>, mode: u32, ) -> VfResult<()>
pub fn read_dir(&self, path: impl AsRef<Path>) -> VfResult<Vec<DirEntry>>
Sourcepub fn read_dir_with_options(
&self,
path: impl AsRef<Path>,
options: ReadDirOptions,
) -> VfResult<Vec<DirEntry>>
pub fn read_dir_with_options( &self, path: impl AsRef<Path>, options: ReadDirOptions, ) -> VfResult<Vec<DirEntry>>
Read one directory with explicit entry and path-storage limits.
Source§impl<F: DirectoryFileSystem + MetadataFileSystem> FsClient<F>
impl<F: DirectoryFileSystem + MetadataFileSystem> FsClient<F>
Source§impl<F: NamespaceFileSystem + MetadataFileSystem> FsClient<F>
impl<F: NamespaceFileSystem + MetadataFileSystem> FsClient<F>
pub fn remove_file(&self, path: impl AsRef<Path>) -> VfResult<()>
pub fn remove_dir(&self, path: impl AsRef<Path>) -> VfResult<()>
pub fn remove_dir_all(&self, path: impl AsRef<Path>) -> VfResult<()>
Sourcepub fn remove_dir_contents(&self, path: impl AsRef<Path>) -> VfResult<()>
pub fn remove_dir_contents(&self, path: impl AsRef<Path>) -> VfResult<()>
Remove the contents of a directory, keeping the directory itself.
pub fn rename( &self, from: impl AsRef<Path>, to: impl AsRef<Path>, ) -> VfResult<()>
Source§impl<F: VecFs> FsClient<F>
impl<F: VecFs> FsClient<F>
Sourcepub fn ensure_empty_dir(&self, path: impl AsRef<Path>) -> VfResult<()>
pub fn ensure_empty_dir(&self, path: impl AsRef<Path>) -> VfResult<()>
Create path if missing, otherwise empty it. Errors if it exists and is
not a directory (a symlink to a directory is not a directory here).
Sourcepub fn open_dir(&self, path: impl AsRef<Path>) -> VfResult<VfDir>
pub fn open_dir(&self, path: impl AsRef<Path>) -> VfResult<VfDir>
Open a directory for handle-rooted removal. The returned handle cannot
be swapped for a symlink between opening and removal; release it with
close_dir.
Sourcepub fn remove_dir_contents_handle(&self, dir: &VfDir) -> VfResult<()>
pub fn remove_dir_contents_handle(&self, dir: &VfDir) -> VfResult<()>
Remove the contents of a directory handle, keeping the directory.
Source§impl<F: LinkFileSystem> FsClient<F>
impl<F: LinkFileSystem> FsClient<F>
Source§impl<F: CopyFileSystem> FsClient<F>
impl<F: CopyFileSystem> FsClient<F>
Source§impl<F: VectorFileSystem> FsClient<F>
impl<F: VectorFileSystem> FsClient<F>
Sourcepub fn openv(&self, requests: &[OpenRequest]) -> VfResult<Vec<FsFile<F>>>
pub fn openv(&self, requests: &[OpenRequest]) -> VfResult<Vec<FsFile<F>>>
Open an ordered vector of files.
Success returns one RAII handle per request. Failure returns no handles; VFSI does not promise transactional rollback of other filesystem effects such as file creation.
Sourcepub fn closev(&self, files: Vec<FsFile<F>>) -> VfResult<()>
pub fn closev(&self, files: Vec<FsFile<F>>) -> VfResult<()>
Close a group of files through one vector operation.
On failure, each handle remains armed for best-effort cleanup on drop; explicitly closed prefix handles may consequently receive a harmless second close attempt.