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§

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

Source

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

Source

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

Source

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

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.