Trait StorageExt

Source
pub trait StorageExt: Storage {
    // Required methods
    async fn readv(&self, bufv: IoVectorMut<'_>, offset: u64) -> Result<()>;
    async fn writev(&self, bufv: IoVector<'_>, offset: u64) -> Result<()>;
    async fn read(
        &self,
        buf: impl Into<IoVectorMut<'_>>,
        offset: u64,
    ) -> Result<()>;
    async fn write(
        &self,
        buf: impl Into<IoVector<'_>>,
        offset: u64,
    ) -> Result<()>;
    async fn write_zeroes(&self, offset: u64, length: u64) -> Result<()>;
    async fn discard(&self, offset: u64, length: u64) -> Result<()>;
    async fn weak_write_blocker(
        &self,
        range: Range<u64>,
    ) -> RangeBlockedGuard<'_>;
    async fn strong_write_blocker(
        &self,
        range: Range<u64>,
    ) -> RangeBlockedGuard<'_>;
}
Expand description

Helper methods for storage objects.

Provides some more convenient methods for accessing storage objects.

Required Methods§

Source

async fn readv(&self, bufv: IoVectorMut<'_>, offset: u64) -> Result<()>

Read data at offset into bufv.

Reads until bufv is filled completely, i.e. will not do short reads. When reaching the end of file, the rest of bufv is filled with 0.

Checks alignment. If anything does not meet the requirements, enforces it (using ephemeral bounce buffers).

Source

async fn writev(&self, bufv: IoVector<'_>, offset: u64) -> Result<()>

Write data from bufv to offset.

Writes all data from bufv, i.e. will not do short writes. When reaching the end of file, it is grown as necessary so that the new end of file will be at offset + bufv.len().

If growing is not possible, expect writes beyond the end of file (even if only partially) to fail.

Checks alignment. If anything does not meet the requirements, enforces it using bounce buffers and a read-modify-write cycle that blocks concurrent writes to the affected area.

Source

async fn read(&self, buf: impl Into<IoVectorMut<'_>>, offset: u64) -> Result<()>

Read data at offset into buf.

Reads until buf is filled completely, i.e. will not do short reads. When reaching the end of file, the rest of buf is filled with 0.

Checks alignment. If anything does not meet the requirements, enforces it (using ephemeral bounce buffers).

Source

async fn write(&self, buf: impl Into<IoVector<'_>>, offset: u64) -> Result<()>

Write data from buf to offset.

Writes all data from buf, i.e. will not do short writes. When reaching the end of file, it is grown as necessary so that the new end of file will be at offset + buf.len().

If growing is not possible, expect writes beyond the end of file (even if only partially) to fail.

Checks alignment. If anything does not meet the requirements, enforces it using bounce buffers and a read-modify-write cycle that blocks concurrent writes to the affected area.

Source

async fn write_zeroes(&self, offset: u64, length: u64) -> Result<()>

Ensure the given range reads back as zeroes.

Source

async fn discard(&self, offset: u64, length: u64) -> Result<()>

Discard the given range, with undefined contents when read back.

Tell the storage layer this range is no longer needed and need not be backed by actual storage. When read back, the data read will be undefined, i.e. not necessarily zeroes.

Source

async fn weak_write_blocker(&self, range: Range<u64>) -> RangeBlockedGuard<'_>

Await concurrent strong write blockers for the given range.

Strong write blockers are set up for writes that must not be intersected by any other write. Await such intersecting concurrent write requests, and return a guard that will delay such new writes until the guard is dropped.

Source

async fn strong_write_blocker(&self, range: Range<u64>) -> RangeBlockedGuard<'_>

Await any concurrent write request for the given range.

Block the given range for any concurrent write requests until the returned guard object is dropped. Existing requests are awaited, and new ones will be delayed.

Dyn Compatibility§

This trait is not dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.

Implementors§