Skip to main content

FsClient

Struct FsClient 

Source
pub struct FsClient<F> { /* private fields */ }
Expand description

Cloneable owner of one synchronous backend connection.

Implementations§

Source§

impl<F> FsClient<F>

Source

pub fn new(filesystem: F) -> Self

Source

pub fn into_inner(self) -> Result<F, Self>

Source§

impl<F: FileSystem> FsClient<F>

Source

pub fn open(&self, path: impl AsRef<Path>) -> VfResult<FsFile<F>>

Open a path read-only.

Source

pub fn open_with(&self, request: OpenRequest) -> VfResult<FsFile<F>>

Source

pub fn open_options(&self) -> OpenOptions<'_, F>

Source

pub fn create(&self, path: impl AsRef<Path>) -> VfResult<FsFile<F>>

Source

pub fn read(&self, path: impl AsRef<Path>) -> VfResult<Vec<u8>>

Source

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.

Source

pub fn read_to_string(&self, path: impl AsRef<Path>) -> VfResult<String>

Source

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.

Source

pub fn write(&self, path: impl AsRef<Path>, data: &[u8]) -> VfResult<()>

Source§

impl<F: FileSystem> FsClient<F>

Source

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

pub fn read_stream_with_options( &self, path: impl AsRef<Path>, options: ReadStreamOptions, callback: impl FnMut(u64, &[u8]) -> VfResult<bool>, ) -> VfResult<()>

Stream one file using an explicit maximum chunk size.

Source§

impl<F: MetadataFileSystem> FsClient<F>

Source

pub fn metadata(&self, path: impl AsRef<Path>) -> VfResult<Metadata>

Source

pub fn set_metadata(&self, path: impl AsRef<Path>) -> SetMetadata<'_, F>

Source§

impl<F: DirectoryFileSystem> FsClient<F>

Source

pub fn create_dir(&self, path: impl AsRef<Path>) -> VfResult<()>

Source

pub fn create_dir_with_mode( &self, path: impl AsRef<Path>, mode: u32, ) -> VfResult<()>

Source

pub fn read_dir(&self, path: impl AsRef<Path>) -> VfResult<Vec<DirEntry>>

Source

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

pub fn visit_dir( &self, path: impl AsRef<Path>, callback: impl FnMut(DirEntry) -> VfResult<bool>, ) -> VfResult<()>

Visit one directory incrementally without retaining all entries in the application. The callback runs under the backend lock and must not call this client or drop other files owned by it.

Source

pub fn visit_dir_with_options( &self, path: impl AsRef<Path>, options: ReadDirOptions, callback: impl FnMut(DirEntry) -> VfResult<bool>, ) -> VfResult<()>

Visit entries with explicit entry and cumulative path-byte limits.

Source§

impl<F: DirectoryFileSystem + MetadataFileSystem> FsClient<F>

Source

pub fn create_dir_all(&self, path: impl AsRef<Path>) -> VfResult<()>

Source§

impl<F: NamespaceFileSystem + MetadataFileSystem> FsClient<F>

Source

pub fn remove_file(&self, path: impl AsRef<Path>) -> VfResult<()>

Source

pub fn remove_dir(&self, path: impl AsRef<Path>) -> VfResult<()>

Source

pub fn remove_dir_all(&self, path: impl AsRef<Path>) -> VfResult<()>

Source

pub fn remove_dir_contents(&self, path: impl AsRef<Path>) -> VfResult<()>

Remove the contents of a directory, keeping the directory itself.

Source

pub fn rename( &self, from: impl AsRef<Path>, to: impl AsRef<Path>, ) -> VfResult<()>

Source§

impl<F: VecFs> FsClient<F>

Source

pub fn read_dirs<P: AsRef<Path>>( &self, paths: &[P], ) -> VfResult<Vec<DirectoryListing>>

List several directories with common stat attributes and finite allocation limits. Use read_dirs_with_options for richer fields.

Source

pub fn walk(&self, root: impl AsRef<Path>) -> VfResult<Vec<DirectoryListing>>

Recursively enumerate a bounded tree with common stat attributes. Use walk_with_options to select fields or change limits.

Source

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).

Source

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.

Source

pub fn remove_dir_contents_handle(&self, dir: &VfDir) -> VfResult<()>

Remove the contents of a directory handle, keeping the directory.

Source

pub fn close_dir(&self, dir: &VfDir) -> VfResult<()>

Release a handle from open_dir.

Source§

impl<F: LinkFileSystem> FsClient<F>

Source§

impl<F: CopyFileSystem> FsClient<F>

Source

pub fn copy( &self, source: impl AsRef<Path>, destination: impl AsRef<Path>, ) -> VfResult<()>

Source§

impl<F: VecFs> FsClient<F>

Fetch selected metadata for one path without following its final symlink. Unavailable fields remain None on Metadata.

Source

pub fn read_dirs_with_options<P: AsRef<Path>>( &self, paths: &[P], fields: AttrMask, options: ReadDirOptions, ) -> VfResult<Vec<DirectoryListing>>

List multiple directories in a vector call. The limits apply to the aggregate returned entries and stored path bytes. Streaming backends apply these limits before collecting a full listing; a backend using the compatibility visit_dir fallback may buffer one directory first. An error discards the collected prefix; callers may retry individual directories if desired.

Source

pub fn walk_with_options( &self, root: impl AsRef<Path>, fields: AttrMask, options: WalkOptions, ) -> VfResult<Vec<DirectoryListing>>

Recursively enumerate directories with selected entry attributes. The walk is bounded by options; sorting and presentation remain the application’s responsibility.

Source

pub fn copy_files<P: AsRef<Path>, Q: AsRef<Path>>( &self, pairs: &[(P, Q)], ) -> VfResult<()>

Copy whole files in request order. A successful prefix may remain if a later request fails; this operation does not provide atomicity.

Source

pub fn remove_paths<P: AsRef<Path>>( &self, paths: &[P], recursive: bool, ) -> VfResult<()>

Remove paths in request order, optionally recursing into directories. A successful prefix may remain if a later path fails.

Fetch no-follow metadata for many paths using the backend’s vector operation. Useful for routing without one metadata RPC per path.

Source§

impl<F: VectorFileSystem> FsClient<F>

Source

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.

Source

pub fn try_closev(&self, files: &mut [FsFile<F>]) -> VfResult<()>

Try to close a group through one vector operation without consuming the handles. On failure, all handles remain armed: the backend may have closed a prefix, so callers must reconcile before retrying.

Source

pub fn closev(&self, files: Vec<FsFile<F>>) -> VfResult<()>

Close a group of files through one vector operation.

On failure, the handles are dropped and the backend receives best-effort scalar cleanup attempts. Use try_closev to retain the handles after an error.

Source

pub fn readv(&self, requests: &[FsRead<'_, F>]) -> VfResult<Vec<ReadResult>>

Read an ordered vector with a 16 MiB aggregate request limit. Use readv_with_limit to tune the limit or readv_into to provide bounded caller-owned buffers.

Source

pub fn readv_with_limit( &self, requests: &[FsRead<'_, F>], max_total_bytes: usize, ) -> VfResult<Vec<ReadResult>>

Read an ordered vector with an explicit aggregate request limit.

Source

pub fn readv_into( &self, requests: &mut [FsReadInto<'_, F>], ) -> VfResult<Vec<usize>>

Source

pub fn writev(&self, requests: &[FsWrite<'_, F>]) -> VfResult<Vec<WriteResult>>

Source

pub fn write_allv( &self, requests: &[FsWrite<'_, F>], ) -> VfResult<Vec<WriteResult>>

Write every byte in each positional request, retrying short writes in vector waves. Like writev, this is not transactional: an error may follow a successfully written prefix. Overlapping requests through the same path complete in input order; different paths are presumed independent (including hard-link aliases).

Source§

impl<F: VectorFileSystem + VecFs> FsClient<F>

Source

pub fn read_files<P: AsRef<Path>>(&self, paths: &[P]) -> VfResult<Vec<Vec<u8>>>

Read several complete files by path using vector READ operations.

The aggregate returned data is limited to 16 MiB by default. Use read_files_with_options to choose a different limit, or stream large files instead. This is not a snapshot or an atomic operation across files.

Source

pub fn read_files_with_options<P: AsRef<Path>>( &self, paths: &[P], options: ReadAllOptions, ) -> VfResult<Vec<Vec<u8>>>

Read several complete files with an explicit aggregate allocation limit.

Source

pub fn write_files<P: AsRef<Path>, B: AsRef<[u8]>>( &self, entries: &[(P, B)], ) -> VfResult<()>

Replace several files from borrowed buffers using vector OPEN, WRITE, and CLOSE phases. Identical path spellings are rejected before opening anything; aliases such as hard links are still the caller’s responsibility. The batch is not transactional: an error may follow files already created or written. Large inputs should be chunked by the caller rather than held in memory solely for this convenience method.

Trait Implementations§

Source§

impl<F> Clone for FsClient<F>

Source§

fn clone(&self) -> Self

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl<F> Debug for FsClient<F>

Source§

fn fmt(&self, formatter: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more

Auto Trait Implementations§

§

impl<F> Freeze for FsClient<F>
where Arc<Mutex<F>>: Freeze,

§

impl<F> RefUnwindSafe for FsClient<F>
where Arc<Mutex<F>>: RefUnwindSafe,

§

impl<F> Send for FsClient<F>
where Arc<Mutex<F>>: Send,

§

impl<F> Sync for FsClient<F>
where Arc<Mutex<F>>: Sync,

§

impl<F> Unpin for FsClient<F>
where Arc<Mutex<F>>: Unpin,

§

impl<F> UnsafeUnpin for FsClient<F>
where Arc<Mutex<F>>: UnsafeUnpin,

§

impl<F> UnwindSafe for FsClient<F>
where Arc<Mutex<F>>: UnwindSafe,

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = !

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, !>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.