Skip to main content

FileHandle

Trait FileHandle 

Source
pub trait FileHandle {
    // Required methods
    fn path(&self) -> &Path;
    fn try_close(&mut self) -> Result<(), VfError>;
    fn is_closed(&self) -> bool;
    fn close(self) -> Result<(), VfError>
       where Self: Sized;
}
Expand description

Owned handle to one open file instance.

A descriptor is the handle to the instance; this contract does not require exposing a numeric OS descriptor. crate::Fd is a backend-assigned numeric slot, while implementations such as vfsi_sync::OpenFile own cleanup.

This is neither an underlying filesystem-object ID nor a protocol filehandle such as an NFS filehandle. Separate opens of the same object yield separate instances. Borrowed requests preserve the instance’s lifetime; clients validate connection ownership before dispatch.

Clients validate ownership before I/O and report positional progress. Standard-I/O adapters manage their own independent cursors. ReadOp borrows handles directly; constructing it does no I/O. A backend must retain ownership of live descriptors through cleanup failures.

Required Methods§

Source

fn path(&self) -> &Path

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

Source

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.

Source

fn is_closed(&self) -> bool

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

Source

fn close(self) -> Result<(), VfError>
where Self: Sized,

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.

Dyn Compatibility§

This trait is dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety".

Implementors§