pub struct OpenedFile<B: Buffering = Cached> { /* private fields */ }Expand description
A file this crate opened, in buffering mode B: a SharedHandle and what is known of it
because of how it was opened. Cloning shares the one handle.
It is what a Win32FileTarget is made from, and the only thing it
can be made from; the module documentation says why.
A consumer that needs the stronger warranty says so in its signature, and a cached file cannot be passed:
use win_durable_ioring::windows_backend::{Cached, FileOptions, OpenedFile, Unbuffered};
fn needs_an_unbuffered_file(_: OpenedFile<Unbuffered>) {}
let cached = OpenedFile::<Cached>::open("a-file", FileOptions::new().read(true)).unwrap();
needs_an_unbuffered_file(cached);Implementations§
Source§impl<B: Buffering> OpenedFile<B>
impl<B: Buffering> OpenedFile<B>
Sourcepub fn open(path: impl AsRef<Path>, options: FileOptions) -> Result<Self>
pub fn open(path: impl AsRef<Path>, options: FileOptions) -> Result<Self>
Open path as options says, in buffering mode B.
§Errors
Whatever the open reports, and RemoteDevice (as an io::ErrorKind::Unsupported error)
when B can claim its warranty only on a local device and path is on a remote one. That
is decided from the path’s final location, which resolves links and mapped drives, before
anything is created; the file can still be replaced by a link in the time between.
Sourcepub fn handle(&self) -> &SharedHandle
pub fn handle(&self) -> &SharedHandle
The file’s handle, owned and shared.
Source§impl OpenedFile<Unbuffered>
impl OpenedFile<Unbuffered>
Sourcepub fn with_sector_size(self, sector_size: u32) -> Result<Self, GeometryError>
pub fn with_sector_size(self, sector_size: u32) -> Result<Self, GeometryError>
State the device’s sector size, for a device whose sectors are smaller than
Unbuffered::DEFAULT_SECTOR_SIZE. A size that is too small for the device is refused by
the device on the first transfer that needs more, as an error on that operation’s
completion, never as silent damage.
§Errors
GeometryError if sector_size is not a power of two.