Skip to main content

OpenedFile

Struct OpenedFile 

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

Source

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.

Source

pub fn handle(&self) -> &SharedHandle

The file’s handle, owned and shared.

Source

pub fn geometry(&self) -> Geometry

The alignment its operations need.

Source§

impl OpenedFile<Unbuffered>

Source

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.

Trait Implementations§

Source§

impl<B: Buffering> AsHandle for OpenedFile<B>

Source§

fn as_handle(&self) -> BorrowedHandle<'_>

Borrows the handle. Read more
Source§

impl<B: Buffering> AsRawHandle for OpenedFile<B>

Source§

fn as_raw_handle(&self) -> RawHandle

Extracts the raw handle. Read more
Source§

impl<B: Clone + Buffering> Clone for OpenedFile<B>

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<B: Debug + Buffering> Debug for OpenedFile<B>

Source§

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

Formats the value using the given formatter. Read more

Auto Trait Implementations§

§

impl<B> Freeze for OpenedFile<B>
where PhantomData<B>: Freeze,

§

impl<B> RefUnwindSafe for OpenedFile<B>

§

impl<B> Send for OpenedFile<B>
where PhantomData<B>: Send,

§

impl<B> Sync for OpenedFile<B>
where PhantomData<B>: Sync,

§

impl<B> Unpin for OpenedFile<B>
where PhantomData<B>: Unpin,

§

impl<B> UnsafeUnpin for OpenedFile<B>

§

impl<B> UnwindSafe for OpenedFile<B>

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.