Struct fuse_backend_rs::common::file_buf::FileVolatileBuf

source ·
pub struct FileVolatileBuf { /* private fields */ }
Expand description

An adapter structure to support io-uring based asynchronous IO.

The tokio-uring framework needs to take ownership of data buffers during asynchronous IO operations. The FileVolatileBuf converts a referenced buffer to a buffer compatible with the tokio-uring APIs.

§Safety

The buffer is borrowed without a lifetime parameter, so the caller must ensure that the FileVolatileBuf object doesn’t out-live the borrowed buffer. And during the lifetime of the FileVolatileBuf object, the referenced buffer must be stable.

Implementations§

source§

impl FileVolatileBuf

source

pub unsafe fn new(buf: &mut [u8]) -> Self

Create a FileVolatileBuf object from a mutable slice, eliding the lifetime associated with the slice.

§Safety

The caller needs to guarantee that the returned FileVolatileBuf object doesn’t out-live the referenced buffer. The caller must also guarantee that all other users of the given chunk of memory are using volatile accesses.

source

pub unsafe fn new_with_data(buf: &mut [u8], size: usize) -> Self

Create a FileVolatileBuf object containing size bytes of initialized data from a mutable slice, eliding the lifetime associated with the slice.

§Safety

The caller needs to guarantee that the returned FileVolatileBuf object doesn’t out-live the referenced buffer. The caller must also guarantee that all other users of the given chunk of memory are using volatile accesses.

§Panic

Panic if size is bigger than buf.len().

source

pub unsafe fn from_raw_ptr(addr: *mut u8, size: usize, cap: usize) -> Self

Create a FileVolatileBuf object from a raw pointer.

§Safety

The caller needs to guarantee that the returned FileVolatileBuf object doesn’t out-live the referenced buffer. The caller must also guarantee that all other users of the given chunk of memory are using volatile accesses.

§Panic

Panic if size is bigger than cap.

source

pub fn io_slice(&self) -> IoSlice<'_>

Generate an IoSlice object to read data from the buffer.

source

pub fn io_slice_mut(&self) -> IoSliceMut<'_>

Generate an IoSliceMut object to write data into the buffer.

source

pub fn cap(&self) -> usize

Get capacity of the buffer.

source

pub fn is_empty(&self) -> bool

Check whether the buffer is empty.

source

pub fn len(&self) -> usize

Get size of initialized data in the buffer.

source

pub unsafe fn set_size(&mut self, size: usize)

Set size of initialized data in the buffer.

§Safety

Caller needs to ensure size is less than or equal to cap.

Trait Implementations§

source§

impl Clone for FileVolatileBuf

source§

fn clone(&self) -> FileVolatileBuf

Returns a copy of the value. Read more
1.0.0 · source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
source§

impl Debug for FileVolatileBuf

source§

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

Formats the value using the given formatter. Read more
source§

impl Copy for FileVolatileBuf

Auto Trait Implementations§

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§

default unsafe fn clone_to_uninit(&self, dst: *mut T)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dst. Read more
source§

impl<T> CloneToUninit for T
where T: Copy,

source§

unsafe fn clone_to_uninit(&self, dst: *mut T)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dst. 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,

§

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

§

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

§

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.