Struct File

Source
pub struct File<D: Drive = DemoDriver<'static>> { /* private fields */ }
Expand description

A file handle that runs on io-uring

Implementations§

Source§

impl File

Source

pub fn open(path: impl AsRef<Path>) -> Open

Open a file using the default driver

Source

pub fn create(path: impl AsRef<Path>) -> Create

Create a new file using the default driver

Source§

impl<D: Drive + Clone> File<D>

Source

pub fn open_on_driver(path: impl AsRef<Path>, driver: D) -> Open<D>

Open a file

Source

pub fn create_on_driver(path: impl AsRef<Path>, driver: D) -> Create<D>

Create a file

Source§

impl<D: Drive> File<D>

Source

pub fn run_on_driver(file: File, driver: D) -> File<D>

Take an existing file and run its IO on an io-uring driver

Source

pub fn read_buffered(&self) -> &[u8]

Access any data that has been read into the buffer, but not consumed

This is similar to the fill_buf method from AsyncBufRead, but instead of performing IO if the buffer is empty, it will just return an empty slice. This method can be used to copy out any left over buffered data before closing or performing a write.

Trait Implementations§

Source§

impl<D: Drive> AsyncBufRead for File<D>

Source§

fn poll_fill_buf( self: Pin<&mut Self>, ctx: &mut Context<'_>, ) -> Poll<Result<&[u8]>>

Attempt to return the contents of the internal buffer, filling it with more data from the inner reader if it is empty. Read more
Source§

fn consume(self: Pin<&mut Self>, amt: usize)

Tells this buffer that amt bytes have been consumed from the buffer, so they should no longer be returned in calls to poll_read. Read more
Source§

impl<D: Drive> AsyncRead for File<D>

Source§

fn poll_read( self: Pin<&mut Self>, ctx: &mut Context<'_>, buf: &mut [u8], ) -> Poll<Result<usize>>

Attempt to read from the AsyncRead into buf. Read more
Source§

fn poll_read_vectored( self: Pin<&mut Self>, cx: &mut Context<'_>, bufs: &mut [IoSliceMut<'_>], ) -> Poll<Result<usize, Error>>

Attempt to read from the AsyncRead into bufs using vectored IO operations. Read more
Source§

impl<D: Drive> AsyncSeek for File<D>

Source§

fn poll_seek( self: Pin<&mut Self>, ctx: &mut Context<'_>, pos: SeekFrom, ) -> Poll<Result<u64>>

Attempt to seek to an offset, in bytes, in a stream. Read more
Source§

impl<D: Drive> AsyncWrite for File<D>

Source§

fn poll_write( self: Pin<&mut Self>, ctx: &mut Context<'_>, slice: &[u8], ) -> Poll<Result<usize>>

Attempt to write bytes from buf into the object. Read more
Source§

fn poll_flush(self: Pin<&mut Self>, ctx: &mut Context<'_>) -> Poll<Result<()>>

Attempt to flush the object, ensuring that any buffered data reach their destination. Read more
Source§

fn poll_close(self: Pin<&mut Self>, ctx: &mut Context<'_>) -> Poll<Result<()>>

Attempt to close the object. Read more
Source§

fn poll_write_vectored( self: Pin<&mut Self>, cx: &mut Context<'_>, bufs: &[IoSlice<'_>], ) -> Poll<Result<usize, Error>>

Attempt to write bytes from bufs into the object using vectored IO operations. Read more
Source§

impl<D: Drive> Drop for File<D>

Source§

fn drop(&mut self)

Executes the destructor for this type. Read more
Source§

impl<D: Drive> From<File<D>> for File

Source§

fn from(file: File<D>) -> File

Converts to this type from the input type.
Source§

impl From<File> for File

Source§

fn from(file: File) -> File

Converts to this type from the input type.

Auto Trait Implementations§

§

impl<D> Freeze for File<D>
where D: Freeze,

§

impl<D = DemoDriver<'static>> !RefUnwindSafe for File<D>

§

impl<D> Send for File<D>
where D: Send,

§

impl<D> Sync for File<D>
where D: Sync,

§

impl<D> Unpin for File<D>
where D: Unpin,

§

impl<D = DemoDriver<'static>> !UnwindSafe for File<D>

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 = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

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.