Skip to main content

FsClient

Struct FsClient 

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

Cloneable owner of one synchronous backend connection. Clones share a mutex and serialize backend calls; use separate connections for parallel RPCs. Explicitly close handles to observe cleanup failures. Handle Drop queues cleanup, drained before later operations or by drain_cleanup. Dropping the final backend owner performs synchronous teardown and may wait for pending closes and backend request timeouts.

Implementations§

Source§

impl<F: FileSystem> FsClient<F>

Source

pub fn new(filesystem: F) -> Self

Source

pub fn with_limits(self, limits: ResourceLimits) -> Self

Configure this client view and its future clones. Existing clones keep their policy; all views still share the same connection and ownership.

Source

pub fn limits(&self) -> ResourceLimits

Source

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

Source

pub fn drain_cleanup(&self) -> VfResult<()>

Drain queued Drop cleanup and report the first failure. Failed targets remain owned for later cleanup. No new file operation is replayed.

Source§

impl<F: FileSystem> FsClient<F>

Source

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

Source§

impl<F: Backend> FsClient<F>

Source

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

Source§

impl<F: Backend> FsClient<F>

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_handle(&self, path: impl AsRef<Path>) -> VfResult<FsDir<F>>

Open a genuine directory handle for race-resistant, handle-rooted removal. Backends that only return a path fail instead of silently losing the handle safety guarantee.

Trait Implementations§

Source§

impl<F: FileSystem> 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: FileSystem> Debug for FsClient<F>

Source§

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

Formats the value using the given formatter. Read more
Source§

impl<F: Backend + 'static> Vfsi for FsClient<F>

Source§

type File = FsFile<F>

Owned handle; vectors must contain handles belonging to this client.
Source§

fn vrename<P: AsRef<Path>, Q: AsRef<Path>>( &self, pairs: &[(P, Q)], options: RenameOptions, ) -> Result<()>

Rename independent pairs in input order using the requested atomic destination behavior. Each pair is atomic where the backend supports the option; the vector is not a transaction, so failures may leave a completed prefix. Source and destination are resolved in this filesystem namespace. Unsupported guarantees return Unsupported rather than being emulated with check-then-rename. Read more
Source§

fn vlistdirs<P: AsRef<Path>>( &self, paths: &[P], options: ListDirOptions, callback: impl FnMut(usize, DirectoryListing) -> Result<ControlFlow<()>>, ) -> Result<Vec<TraversalCompletion>>

Visit shallow directories (default) or recursive trees using bounded pages. Entry/path-byte limits are shared across roots; recursive visits also charge retained directory path bytes. Root index accompanies every owned directory page, including empty directories. Callbacks run outside backend locks and may reenter. Entries for one directory may span several pages. Break stops the whole vector. The returned prefix covers every root whose pages reached the callback; unfinished roots are Stopped. Pages may interleave between roots. Read more
Source§

fn vstream<P: AsRef<Path>>( &self, paths: &[P], options: StreamOptions, callback: impl FnMut(usize, u64, &[u8]) -> Result<bool>, ) -> Result<Vec<StreamCompletion>>

Stream files through bounded chunks without collecting whole contents. The callback receives the input index, byte offset, and borrowed chunk. False stops the whole vector; results contain its completed/stopped prefix. Backends may process streams sequentially; this is not a parallelism promise. Read more
Source§

fn capabilities(&self) -> Result<Capabilities>

Capabilities supported by this client. Routed clients report capabilities common to their routes; support does not imply authorization for a path.
Create symbolic links from (target text, link path) pairs. Targets are stored verbatim, including relative or dangling targets. Parents must exist. Errors may follow partial creation; no rollback.
Read symbolic link targets in input order without following final links. Returns their original path bytes, including non-UTF-8 names on Unix. An error identifies the input when known and discards collected results.
Create hard links from (existing source, new link path) pairs. Sources are not followed when the final component is a symlink. Cross-filesystem links can fail. Errors may follow partial creation.
Source§

fn vstatfs<P: MetadataOperand<Self::File>>( &self, targets: &[P], ) -> Result<Vec<FilesystemStats>>

Query filesystems for paths (following symlinks) and retained open handles. Results preserve input order. Unsupported fields are None.
Source§

fn vsetattrs<P: MetadataOperand<Self::File>>( &self, updates: &[(P, MetadataUpdate)], follow_symlinks: bool, ) -> Result<()>

Update selected attributes for paths or open handles using native batching. Every handle is validated before dispatch, including ownership and closure. Unspecified fields are unchanged. follow_symlinks controls the final component of path targets; it does not change open-handle identity. Ancestor symlinks retain ordinary backend resolution. Failure can follow partial mutations, including within one request; an error index identifies an input, not a committed-prefix count. Empty vectors succeed without I/O. Do not replay ambiguous failures. Read more
Source§

fn vgetattrs<P: AsRef<Path>>( &self, paths: &[P], options: AttrsOptions, ) -> Result<Vec<Attrs>>

Query metadata in input order with selected fields and final-symlink behavior. Backend execution must preserve vector batching. Ancestor symlinks use ordinary namespace resolution; this is not a snapshot or confinement API. Read more
Source§

fn limits(&self) -> ResourceLimits

Collection/batch defaults, not a process memory cap or file-reader cap. Read more
Source§

fn vopen(&self, requests: &[OpenOp]) -> Result<Vec<Self::File>>

Strict ordered OPEN results. Failure releases returned handles but cannot undo files created/truncated earlier; index() is not a progress count. Read more
Source§

fn vread<'a>( &self, ops: impl IntoIterator<Item = ReadOp<'a, Self::File>>, options: ReadOptions, ) -> Result<Vec<ReadResult>>

Consume a read batch with an explicit aggregate logical-byte budget. Large files should usually be streamed instead of increasing the budget. Explicit options override client defaults. Read more
Source§

fn vwrite<'a>( &self, requests: &[WriteOp<'a, Self::File>], options: WriteOptions, ) -> Result<Vec<WriteResult>>

Write positional ranges with explicit short-write policy. With default options, report accepted byte counts without completing short writes. With write_all(true), finish short writes after whole-batch local preflight. Backend failures can still follow mutations; aliasing paths are the caller’s responsibility and do not imply transactional ordering. Read more
Source§

fn vclose(&self, files: &mut [Self::File]) -> Result<()>

Retain handles for failed cleanup; completed groups can already be closed. A lost reply leaves remote state ambiguous, not safely open. Read more
Source§

fn vmkdir<P: AsRef<Path>>(&self, paths: &[(P, u32)]) -> Result<()>

Strict vector directory creation. Parents must already exist; errors can follow completed mutations, and do not imply rollback. Read more
Source§

fn vcopy<P: AsRef<Path>, Q: AsRef<Path>>( &self, pairs: &[(P, Q)], options: CopyOption, ) -> Result<()>

Strict file-copy batches; a failed call can have copied earlier files. Read more
Source§

fn vremove<P: AsRef<Path>>( &self, paths: &[P], mode: RemoveMode, options: RemoveOptions, ) -> Result<()>

Remove entries, recursive trees, or directory contents with explicit policy. Read more

Auto Trait Implementations§

§

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

§

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

§

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

§

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

§

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

§

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

§

impl<F> UnwindSafe for FsClient<F>
where Arc<SharedBackend<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.
Source§

impl<C> VfsiExt for C
where C: Vfsi + ?Sized,

Source§

fn statfs<P>(&self, target: P) -> Result<FilesystemStats, VfError>
where P: MetadataOperand<Self::File>,

Query one target through the vector filesystem-statistics engine.
Source§

fn open(&self, path: impl AsRef<Path>) -> Result<Self::File, VfError>

Single-target convenience. For multiple files, prefer Vfsi::vopen to expose batching opportunities. Read more
Source§

fn create(&self, path: impl AsRef<Path>) -> Result<Self::File, VfError>

Single-target convenience. For multiple creations, prefer Vfsi::vopen with CREATE/TRUNCATE flags. Read more
Source§

fn open_with(&self, request: OpenOp) -> Result<Self::File, VfError>

Single-target convenience. For multiple requests, prefer Vfsi::vopen with per-file flags and modes. Read more
Source§

fn close_files(&self, files: Vec<Self::File>) -> Result<(), VfError>

Consume all handles. Errors cannot return cleanup ownership; Drop is best-effort. Prefer vclose when close errors require reconciliation. Read more
Source§

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

Read one complete file within the client’s aggregate read budget. Read more
Source§

fn read_with_options( &self, path: impl AsRef<Path>, options: ReadOptions, ) -> Result<Vec<u8>, VfError>

Read one complete file with an explicit read policy.
Source§

fn read_files<P>(&self, paths: &[P]) -> Result<Vec<Vec<u8>>, VfError>
where P: AsRef<Path>,

Read complete files in input order using vectorized whole-file reads. Read more
Source§

fn read_files_with_options<P>( &self, paths: &[P], options: ReadOptions, ) -> Result<Vec<Vec<u8>>, VfError>
where P: AsRef<Path>,

Whole-file convenience reads with an explicit aggregate payload budget. Read more
Source§

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

Single-target convenience. For multiple files, prefer Vfsi::vread with whole-file operations and decode each result as UTF-8. Read more
Source§

fn read_to_string_with_options( &self, path: impl AsRef<Path>, options: ReadOptions, ) -> Result<String, VfError>

Single-target convenience. For multiple files, prefer Vfsi::vread with an aggregate byte budget, then decode UTF-8. Read more
Source§

fn read_stream( &self, path: impl AsRef<Path>, callback: impl FnMut(u64, &[u8]) -> Result<bool, VfError>, ) -> Result<StreamCompletion, VfError>

Single-target convenience. For multiple files, prefer Vfsi::vstream. Backends may process streams sequentially. Read more
Source§

fn read_stream_with_options( &self, path: impl AsRef<Path>, options: StreamOptions, callback: impl FnMut(u64, &[u8]) -> Result<bool, VfError>, ) -> Result<StreamCompletion, VfError>

Single-target convenience. For multiple files, prefer Vfsi::vstream. Backends may process streams sequentially. Read more
Source§

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

Single-target convenience. For multiple complete files, prefer VfsiExt::write_files; for opened handles, prefer Vfsi::vwrite. Read more
Source§

fn write_files<P, B>(&self, entries: &[(P, B)]) -> Result<(), VfError>
where P: AsRef<Path>, B: AsRef<[u8]>,

Replace files in vector phases. Success completes payloads; errors may follow create/truncate/write effects and never authorize blind replay. Read more
Source§

fn attrs(&self, path: impl AsRef<Path>) -> Result<Attrs, VfError>

Single-target convenience. For multiple paths, prefer Vfsi::vgetattrs. Read more
Source§

fn attrs_with_options( &self, path: impl AsRef<Path>, options: AttrsOptions, ) -> Result<Attrs, VfError>

Single-target convenience. For multiple paths, prefer Vfsi::vgetattrs with selected fields and follow_symlinks(false). Read more
Single-target convenience. For multiple paths, prefer Vfsi::vgetattrs with follow_symlinks(false). Read more
Source§

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

Single-target convenience. For multiple directories, prefer VfsiExt::read_dirs_with_options or VfsiExt::read_dirs. Read more
Source§

fn read_dir_with_options( &self, path: impl AsRef<Path>, options: ListDirOptions, ) -> Result<Vec<DirEntry>, VfError>

Single-target convenience. For multiple directories, prefer VfsiExt::read_dirs_with_options with one aggregate budget. Read more
Source§

fn read_dirs<P>(&self, paths: &[P]) -> Result<Vec<DirectoryListing>, VfError>
where P: AsRef<Path>,

Collect directory listings under one aggregate entry/path-byte policy. Read more
Source§

fn read_dirs_with_options<P>( &self, paths: &[P], options: ListDirOptions, ) -> Result<Vec<Vec<DirectoryListing>>, VfError>
where P: AsRef<Path>,

Collect shallow directories or recursive trees, grouped by input root. Read more
Source§

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

Single-target convenience. For multiple roots, prefer VfsiExt::read_dirs_with_options. Read more
Source§

fn walk_with_options( &self, path: impl AsRef<Path>, options: ListDirOptions, ) -> Result<Vec<DirectoryListing>, VfError>

Single-target convenience. For multiple roots, prefer VfsiExt::read_dirs_with_options with one aggregate budget. Read more
Source§

fn visit_dir( &self, path: impl AsRef<Path>, callback: impl FnMut(&DirEntry) -> Result<ControlFlow<()>, VfError>, ) -> Result<TraversalCompletion, VfError>

Single-target convenience. For multiple directories, prefer Vfsi::vlistdirs. Read more
Source§

fn visit_walk( &self, root: impl AsRef<Path>, callback: impl FnMut(&DirEntry) -> Result<ControlFlow<()>, VfError>, ) -> Result<TraversalCompletion, VfError>

Single-target convenience. For multiple roots, prefer Vfsi::vlistdirs. Read more
Source§

fn visit_dir_with_options( &self, path: impl AsRef<Path>, options: ListDirOptions, callback: impl FnMut(&DirEntry) -> Result<ControlFlow<()>, VfError>, ) -> Result<TraversalCompletion, VfError>

Single-target convenience. For multiple directories, prefer Vfsi::vlistdirs. Read more
Source§

fn visit_entries_with_options<P>( &self, paths: &[P], options: ListDirOptions, callback: impl FnMut(usize, &DirEntry) -> Result<ControlFlow<()>, VfError>, ) -> Result<Vec<TraversalCompletion>, VfError>
where P: AsRef<Path>,

Visit individual entries using the directory-page primitive. Empty directories produce pages but no entry callbacks.
Source§

fn walk_events_with_options( &self, root: impl AsRef<Path>, fields: AttrMask, options: WalkOptions, sort_by_name: bool, callback: impl FnMut(&WalkEvent) -> Result<WalkControl, VfError>, ) -> Result<TraversalCompletion, VfError>

Single-target convenience. For multiple roots without enter/leave events or subtree pruning, prefer Vfsi::vlistdirs. Keep this helper when those event semantics are required. Read more
Source§

fn visit_dirs_ordered( &self, root: impl AsRef<Path>, fields: AttrMask, options: WalkOptions, order: impl FnMut(&mut [DirEntry]), descend: impl FnMut(&DirEntry) -> bool, visitor: impl FnMut(DirectoryListing, usize) -> Result<WalkControl, VfError>, ) -> Result<TraversalCompletion, VfError>

Visit complete shallow listings in depth-first order with application policy. Read more
Source§

fn create_dir(&self, path: impl AsRef<Path>) -> Result<(), VfError>

Single-target convenience. For multiple independent directories, prefer Vfsi::vmkdir. Read more
Source§

fn truncate<T>(&self, target: T, len: u64) -> Result<(), VfError>
where T: MetadataOperand<Self::File>,

Truncate or extend one path or opened object using Vfsi::vsetattrs.
Source§

fn chmod<T>(&self, target: T, permissions: Permissions) -> Result<(), VfError>
where T: MetadataOperand<Self::File>,

Change permissions on one path or opened object using Vfsi::vsetattrs.
Source§

fn chown<T>( &self, target: T, uid: Option<u32>, gid: Option<u32>, ) -> Result<(), VfError>
where T: MetadataOperand<Self::File>,

Change ownership of one path or opened object through Vfsi::vsetattrs. None leaves the corresponding owner/group unchanged. Use the vector with follow_symlinks = false to change a symlink itself.
Source§

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

Create one directory with explicit Unix permission bits.
Create one symbolic link; submit multiple pairs with Vfsi::vsymlink.
Read one symlink target; submit multiple paths with Vfsi::vreadlink.
Create one hard link; submit multiple pairs with Vfsi::vhardlink.
Source§

fn create_dir_all(&self, path: impl AsRef<Path>) -> Result<(), VfError>

Single-target convenience. For multiple directory creations, prefer Vfsi::vmkdir; plan missing parents before their children. Read more
Source§

fn rename( &self, source: impl AsRef<Path>, destination: impl AsRef<Path>, ) -> Result<(), VfError>

Single-target convenience. For multiple source/destination pairs, prefer Vfsi::vrename. Read more
Source§

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

Single-target convenience. For multiple file pairs, prefer Vfsi::vcopy. Read more
Source§

fn copy_with_options( &self, source: impl AsRef<Path>, destination: impl AsRef<Path>, options: CopyOption, ) -> Result<(), VfError>

Single-target copy with explicit operation semantics; prefer Vfsi::vcopy when submitting multiple pairs.
Source§

fn remove_file(&self, path: impl AsRef<Path>) -> Result<(), VfError>

Single-target convenience. For multiple paths, prefer Vfsi::vremove. That vector API accepts both files and directories. Read more
Source§

fn remove_dir(&self, path: impl AsRef<Path>) -> Result<(), VfError>

Single-target convenience. For multiple paths, prefer Vfsi::vremove. That vector API does not enforce directory-only inputs. Read more
Source§

fn remove_dir_all(&self, path: impl AsRef<Path>) -> Result<(), VfError>

Single-target convenience. For multiple trees, prefer Vfsi::vremove with RemoveMode::Tree. Read more
Source§

fn remove_dir_all_with_options( &self, path: impl AsRef<Path>, options: RemoveOptions, ) -> Result<(), VfError>

Recursively remove one directory using explicit batching and failure policy. The directory is validated before mutation; symlink roots are not followed. Prefer Vfsi::vremove when removing several trees.
Source§

fn remove_dir_contents(&self, path: impl AsRef<Path>) -> Result<(), VfError>

Single-target convenience. For multiple directory roots, prefer Vfsi::vremove. Read more
Source§

fn remove_dir_contents_with_options( &self, path: impl AsRef<Path>, options: RemoveOptions, ) -> Result<(), VfError>

Recursively empty one directory while retaining its root, using explicit batching and failure policy. The root is validated without following a symlink. Prefer Vfsi::vremove for several roots.