pub trait FileHandle:
Read
+ Write
+ Seek {
type ReadRequest<'a>
where Self: 'a;
type ReadIntoRequest<'a>
where Self: 'a;
Show 16 methods
// Required methods
fn path(&self) -> &Path;
fn metadata(&self) -> Result<Metadata, VfError>;
fn read_request_at(
&self,
offset: u64,
length: usize,
) -> Self::ReadRequest<'_>;
fn read_request_at_into<'a>(
&'a self,
offset: u64,
buffer: &'a mut [u8],
) -> Self::ReadIntoRequest<'a>;
fn read_at(&self, buffer: &mut [u8], offset: u64) -> Result<usize, VfError>;
fn write_at(&self, buffer: &[u8], offset: u64) -> Result<usize, VfError>;
fn read_native(&mut self, buffer: &mut [u8]) -> Result<usize, VfError>;
fn read_to_end_with_limit(
&mut self,
max_bytes: usize,
) -> Result<Vec<u8>, VfError>;
fn write_native(&mut self, buffer: &[u8]) -> Result<usize, VfError>;
fn seek_native(&mut self, position: SeekFrom) -> Result<u64, VfError>;
fn sync_data(&self) -> Result<(), VfError>;
fn sync_all(&self) -> Result<(), VfError>;
fn try_close(&mut self) -> Result<(), VfError>;
fn is_closed(&self) -> bool;
fn close(self) -> Result<(), VfError>
where Self: Sized;
// Provided method
fn set_permissions(&self, _permissions: Permissions) -> Result<(), VfError> { ... }
}Expand description
Owned application file. Borrowed requests preserve the file’s lifetime; clients validate connection ownership before dispatching a vector.
External implementations must keep request storage valid for its borrowed lifetime, validate client ownership before I/O, and report positional progress without changing the cursor. Request constructors do no I/O. Associated request types are implementer contracts, not application-facing builders. A backend must retain ownership of live descriptors through cleanup failures.
Required Associated Types§
Sourcetype ReadRequest<'a>
where
Self: 'a
type ReadRequest<'a> where Self: 'a
Borrowed positional read request; constructing it performs no I/O.
Sourcetype ReadIntoRequest<'a>
where
Self: 'a
type ReadIntoRequest<'a> where Self: 'a
Borrowed positional request into a caller-owned destination buffer.
Required Methods§
Sourcefn metadata(&self) -> Result<Metadata, VfError>
fn metadata(&self) -> Result<Metadata, VfError>
Query the opened object, even if its original pathname was renamed.
Sourcefn read_request_at(&self, offset: u64, length: usize) -> Self::ReadRequest<'_>
fn read_request_at(&self, offset: u64, length: usize) -> Self::ReadRequest<'_>
Prepare a non-cursor-changing read for this handle’s owning client.
Sourcefn read_request_at_into<'a>(
&'a self,
offset: u64,
buffer: &'a mut [u8],
) -> Self::ReadIntoRequest<'a>
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.
Sourcefn read_at(&self, buffer: &mut [u8], offset: u64) -> Result<usize, VfError>
fn read_at(&self, buffer: &mut [u8], offset: u64) -> Result<usize, VfError>
Read up to the buffer’s length without changing the cursor; may be short.
Sourcefn write_at(&self, buffer: &[u8], offset: u64) -> Result<usize, VfError>
fn write_at(&self, buffer: &[u8], offset: u64) -> Result<usize, VfError>
Write up to the input’s length without changing the cursor; may be short.
Sourcefn read_native(&mut self, buffer: &mut [u8]) -> Result<usize, VfError>
fn read_native(&mut self, buffer: &mut [u8]) -> Result<usize, VfError>
Cursor-based read retaining structured errors, unlike the Read adapter.
Sourcefn read_to_end_with_limit(
&mut self,
max_bytes: usize,
) -> Result<Vec<u8>, VfError>
fn read_to_end_with_limit( &mut self, max_bytes: usize, ) -> Result<Vec<u8>, VfError>
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.
Sourcefn write_native(&mut self, buffer: &[u8]) -> Result<usize, VfError>
fn write_native(&mut self, buffer: &[u8]) -> Result<usize, VfError>
Cursor-based possibly short write retaining structured errors.
Sourcefn seek_native(&mut self, position: SeekFrom) -> Result<u64, VfError>
fn seek_native(&mut self, position: SeekFrom) -> Result<u64, VfError>
Change the cursor, retaining structured errors unlike Seek.
Sourcefn sync_data(&self) -> Result<(), VfError>
fn sync_data(&self) -> Result<(), VfError>
Request durability of file data; errors are not discarded.
Sourcefn sync_all(&self) -> Result<(), VfError>
fn sync_all(&self) -> Result<(), VfError>
Request durability of file data and metadata supported by the backend.
Sourcefn try_close(&mut self) -> Result<(), VfError>
fn try_close(&mut self) -> Result<(), VfError>
Close without surrendering cleanup ownership on failure. After an ambiguous failure, reconcile/close rather than resume ordinary I/O.
Provided Methods§
Sourcefn set_permissions(&self, _permissions: Permissions) -> Result<(), VfError>
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.
Dyn Compatibility§
This trait is not dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety".