Skip to main content

FsFile

Struct FsFile 

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

Owned RAII file which does not borrow the client.

Dropping an open file attempts a best-effort CLOSE. This can block on the backend mutex and on network I/O; use FsFile::try_close when the close result matters or when its timing must be controlled.

Implementations§

Source§

impl<F: FileSystem> FsFile<F>

Source

pub fn is_closed(&self) -> bool

Whether explicit close has completed successfully on this handle.

Source

pub fn read_at(&self, buffer: &mut [u8], offset: u64) -> VfResult<usize>

Positional read which does not alter the file cursor.

Source

pub fn write_at(&self, buffer: &[u8], offset: u64) -> VfResult<usize>

Positional write which does not alter the file cursor.

Source

pub fn read_request_at(&self, offset: u64, length: usize) -> FsRead<'_, F>

Source

pub fn path(&self) -> &Path

Name used at open, retained for diagnostics; not a current namespace lookup or proof of identity. Handle operations continue to use the opened object even if its pathname changes.

Source

pub fn attrs(&self) -> VfResult<Attrs>

Query metadata for the open object without resolving its path again.

Source

pub fn truncate(&self, len: u64) -> VfResult<()>

Truncate or extend the open file.

Source

pub fn chmod(&self, permissions: Permissions) -> VfResult<()>

Change permissions on the open file through the shared vector engine.

Source

pub fn write_request_at<'a>( &'a self, offset: u64, data: &'a [u8], ) -> FsWrite<'a, F>

Source

pub fn read_request_at_into<'a>( &'a self, offset: u64, buffer: &'a mut [u8], ) -> FsReadInto<'a, F>

Source

pub fn read_native(&mut self, buffer: &mut [u8]) -> VfResult<usize>

Source

pub fn read_to_end_with_limit(&mut self, max_bytes: usize) -> VfResult<Vec<u8>>

Collect the remaining bytes from this opened object, starting at its cursor, with an explicit logical payload limit. This does not reopen its path. Unlike standard Read::read_to_end, allocation is bounded.

An exact-limit read uses at most a one-byte EOF probe. On overflow or I/O failure no buffer is returned and the cursor may have advanced, including the probe byte; this operation does not restore the cursor.

Source

pub fn write_native(&mut self, buffer: &[u8]) -> VfResult<usize>

Source

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

Source

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

Source

pub fn try_close(&mut self) -> VfResult<()>

Attempt to close without consuming the handle. A failed close leaves the handle armed so the caller can reconcile or retry cleanup explicitly. After an ambiguous close failure, remote state is unknown: do not resume data I/O just because is_closed() is false. This is local ownership, not proof that the server still has the descriptor open.

Source

pub fn close(self) -> VfResult<()>

Consume and close the handle. On failure, Drop queues cleanup for a later operation or explicit cleanup drain; use try_close to retain control.

Source

pub fn seek_native(&mut self, position: IoSeekFrom) -> VfResult<u64>

Seek while retaining VfError protocol and path information.

Trait Implementations§

Source§

impl<F: FileSystem> Debug for FsFile<F>

Source§

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

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

impl<F: FileSystem> Drop for FsFile<F>

Source§

fn drop(&mut self)

Executes the destructor for this type. Read more
Source§

fn pin_drop(self: Pin<&mut Self>)

🔬This is a nightly-only experimental API. (pin_ergonomics)
Execute the destructor for this type, but different to Drop::drop, it requires self to be pinned. Read more
Source§

impl<F: FileSystem> FileHandle for FsFile<F>

Source§

type ReadRequest<'a> = FsRead<'a, F> where Self: 'a

Borrowed positional read request; constructing it performs no I/O.
Source§

type ReadIntoRequest<'a> = FsReadInto<'a, F> where Self: 'a

Borrowed positional request into a caller-owned destination buffer.
Source§

fn path(&self) -> &Path

Diagnostic name captured at open; not current path or object identity.
Source§

fn attrs(&self) -> Result<Attrs>

Query the opened object, even if its original pathname was renamed.
Source§

fn read_request_at(&self, offset: u64, length: usize) -> Self::ReadRequest<'_>

Prepare a non-cursor-changing read for this handle’s owning client.
Source§

fn read_request_at_into<'a>( &'a self, offset: u64, buffer: &'a mut [u8], ) -> Self::ReadIntoRequest<'a>

Borrow both the handle and destination until the vector call completes.
Source§

fn read_at(&self, buffer: &mut [u8], offset: u64) -> Result<usize>

Read up to the buffer’s length without changing the cursor; may be short.
Source§

fn write_at(&self, buffer: &[u8], offset: u64) -> Result<usize>

Write up to the input’s length without changing the cursor; may be short.
Source§

fn read_native(&mut self, buffer: &mut [u8]) -> Result<usize>

Cursor-based read retaining structured errors, unlike the Read adapter.
Source§

fn read_to_end_with_limit(&mut self, max_bytes: usize) -> Result<Vec<u8>>

Collect from the current cursor with a caller-selected payload budget. A failed read may advance the cursor; exceeding the limit is an error, not successful truncation. Standard Read::read_to_end is not bounded.
Source§

fn write_native(&mut self, buffer: &[u8]) -> Result<usize>

Cursor-based possibly short write retaining structured errors.
Source§

fn seek_native(&mut self, position: SeekFrom) -> Result<u64>

Change the cursor, retaining structured errors unlike Seek.
Source§

fn sync_data(&self) -> Result<()>

Request durability of file data; errors are not discarded.
Source§

fn sync_all(&self) -> Result<()>

Request durability of file data and metadata supported by the backend.
Source§

fn try_close(&mut self) -> Result<()>

Close without surrendering cleanup ownership on failure. After an ambiguous failure, reconcile/close rather than resume ordinary I/O.
Source§

fn is_closed(&self) -> bool

Local close ownership only, not proof of remote liveness after failure.
Source§

fn close(self) -> Result<()>

Consuming close: on failure the handle is lost and Drop retries cleanup best-effort on a later operation or cleanup drain. Prefer try_close when cleanup failures need reconciliation.
Source§

fn set_permissions(&self, _permissions: Permissions) -> Result<(), VfError>

Change permission bits on the opened object, not by re-resolving its path. The default reports Unsupported; callers must not silently claim preservation.
Source§

impl<F: FileSystem> Read for FsFile<F>

Source§

fn read(&mut self, buffer: &mut [u8]) -> Result<usize>

Pull some bytes from this source into the specified buffer, returning how many bytes were read. Read more
1.36.0 · Source§

fn read_vectored(&mut self, bufs: &mut [IoSliceMut<'_>]) -> Result<usize, Error>

Like read, except that it reads into a slice of buffers. Read more
Source§

fn is_read_vectored(&self) -> bool

🔬This is a nightly-only experimental API. (can_vector)
Determines if this Reader has an efficient read_vectored implementation. Read more
1.0.0 · Source§

fn read_to_end(&mut self, buf: &mut Vec<u8>) -> Result<usize, Error>

Reads all bytes until EOF in this source, placing them into buf. Read more
1.0.0 · Source§

fn read_to_string(&mut self, buf: &mut String) -> Result<usize, Error>

Reads all bytes until EOF in this source, appending them to buf. Read more
1.6.0 · Source§

fn read_exact(&mut self, buf: &mut [u8]) -> Result<(), Error>

Reads the exact number of bytes required to fill buf. Read more
Source§

fn read_buf(&mut self, buf: BorrowedCursor<'_, u8>) -> Result<(), Error>

🔬This is a nightly-only experimental API. (read_buf)
Pull some bytes from this source into the specified buffer. Read more
Source§

fn read_buf_exact( &mut self, cursor: BorrowedCursor<'_, u8>, ) -> Result<(), Error>

🔬This is a nightly-only experimental API. (read_buf)
Reads the exact number of bytes required to fill cursor. Read more
1.0.0 · Source§

fn by_ref(&mut self) -> &mut Self
where Self: Sized,

Creates a “by reference” adapter for this instance of Read. Read more
1.0.0 · Source§

fn bytes(self) -> Bytes<Self> ⓘ
where Self: Sized,

Transforms this Read instance to an Iterator over its bytes. Read more
1.0.0 · Source§

fn chain<R>(self, next: R) -> Chain<Self, R> ⓘ
where R: Read, Self: Sized,

Creates an adapter which will chain this stream with another. Read more
1.0.0 · Source§

fn take(self, limit: u64) -> Take<Self> ⓘ
where Self: Sized,

Creates an adapter which will read at most limit bytes from it. Read more
Source§

fn read_array<const N: usize>(&mut self) -> Result<[u8; N], Error>
where Self: Sized,

🔬This is a nightly-only experimental API. (read_array)
Read and return a fixed array of bytes from this source. Read more
Source§

fn read_le<T>(&mut self) -> Result<T, Error>
where T: FromEndianBytes, Self: Sized,

🔬This is a nightly-only experimental API. (read_le)
Read and return a type (e.g. an integer) in little-endian order. Read more
Source§

fn read_be<T>(&mut self) -> Result<T, Error>
where T: FromEndianBytes, Self: Sized,

🔬This is a nightly-only experimental API. (read_le)
Read and return a type (e.g. an integer) in big-endian order. Read more
Source§

impl<F: FileSystem> Seek for FsFile<F>

Source§

fn seek(&mut self, position: IoSeekFrom) -> Result<u64>

Seek to an offset, in bytes, in a stream. Read more
1.55.0 · Source§

fn rewind(&mut self) -> Result<(), Error>

Rewind to the beginning of a stream. Read more
Source§

fn stream_len(&mut self) -> Result<u64, Error>

🔬This is a nightly-only experimental API. (seek_stream_len)
Returns the length of this stream (in bytes). Read more
1.51.0 · Source§

fn stream_position(&mut self) -> Result<u64, Error>

Returns the current seek position from the start of the stream. Read more
1.80.0 · Source§

fn seek_relative(&mut self, offset: i64) -> Result<(), Error>

Seeks relative to the current position. Read more
Source§

impl<F: FileSystem> Write for FsFile<F>

Source§

fn write(&mut self, buffer: &[u8]) -> Result<usize>

Writes a buffer into this writer, returning how many bytes were written. Read more
Source§

fn flush(&mut self) -> Result<()>

Flushes this output stream, ensuring that all intermediately buffered contents reach their destination. Read more
1.36.0 · Source§

fn write_vectored(&mut self, bufs: &[IoSlice<'_>]) -> Result<usize, Error>

Like write, except that it writes from a slice of buffers. Read more
Source§

fn is_write_vectored(&self) -> bool

🔬This is a nightly-only experimental API. (can_vector)
Determines if this Writer has an efficient write_vectored implementation. Read more
1.0.0 · Source§

fn write_all(&mut self, buf: &[u8]) -> Result<(), Error>

Attempts to write an entire buffer into this writer. Read more
Source§

fn write_all_vectored(&mut self, bufs: &mut [IoSlice<'_>]) -> Result<(), Error>

🔬This is a nightly-only experimental API. (write_all_vectored)
Attempts to write multiple buffers into this writer. Read more
1.0.0 · Source§

fn write_fmt(&mut self, args: Arguments<'_>) -> Result<(), Error>

Writes a formatted string into this writer, returning any error encountered. Read more
1.0.0 · Source§

fn by_ref(&mut self) -> &mut Self
where Self: Sized,

Creates a “by reference” adapter for this instance of Write. Read more

Auto Trait Implementations§

§

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

§

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

§

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

§

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

§

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

§

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

§

impl<F> UnwindSafe for FsFile<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> 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, 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.