pub trait AsyncMmapFileMutExt {
Show 42 methods // Required methods fn as_mut_slice(&mut self) -> &mut [u8] ; fn is_cow(&self) -> bool; fn flush(&self) -> Result<()>; fn flush_async(&self) -> Result<()>; fn flush_range(&self, offset: usize, len: usize) -> Result<()>; fn flush_async_range(&self, offset: usize, len: usize) -> Result<()>; fn truncate<'life0, 'async_trait>( &'life0 mut self, max_sz: u64 ) -> Pin<Box<dyn Future<Output = Result<()>> + Send + 'async_trait>> where Self: 'async_trait, 'life0: 'async_trait; fn drop_remove<'async_trait>( self ) -> Pin<Box<dyn Future<Output = Result<()>> + Send + 'async_trait>> where Self: 'async_trait; fn close_with_truncate<'async_trait>( self, max_sz: i64 ) -> Pin<Box<dyn Future<Output = Result<()>> + Send + 'async_trait>> where Self: 'async_trait; // Provided methods fn slice_mut(&mut self, offset: usize, sz: usize) -> &mut [u8] { ... } fn bytes_mut(&mut self, offset: usize, sz: usize) -> Result<&mut [u8]> { ... } fn zero_range(&mut self, start: usize, end: usize) { ... } fn writer(&mut self, offset: usize) -> Result<AsyncMmapFileWriter<'_>> { ... } fn range_writer( &mut self, offset: usize, len: usize ) -> Result<AsyncMmapFileWriter<'_>> { ... } fn write(&mut self, src: &[u8], offset: usize) -> usize { ... } fn write_all(&mut self, src: &[u8], offset: usize) -> Result<()> { ... } fn write_i8(&mut self, val: i8, offset: usize) -> Result<()> { ... } fn write_i16(&mut self, val: i16, offset: usize) -> Result<()> { ... } fn write_i16_le(&mut self, val: i16, offset: usize) -> Result<()> { ... } fn write_isize(&mut self, val: isize, offset: usize) -> Result<()> { ... } fn write_isize_le(&mut self, val: isize, offset: usize) -> Result<()> { ... } fn write_i32(&mut self, val: i32, offset: usize) -> Result<()> { ... } fn write_i32_le(&mut self, val: i32, offset: usize) -> Result<()> { ... } fn write_i64(&mut self, val: i64, offset: usize) -> Result<()> { ... } fn write_i64_le(&mut self, val: i64, offset: usize) -> Result<()> { ... } fn write_i128(&mut self, val: i128, offset: usize) -> Result<()> { ... } fn write_i128_le(&mut self, val: i128, offset: usize) -> Result<()> { ... } fn write_u8(&mut self, val: u8, offset: usize) -> Result<()> { ... } fn write_u16(&mut self, val: u16, offset: usize) -> Result<()> { ... } fn write_u16_le(&mut self, val: u16, offset: usize) -> Result<()> { ... } fn write_usize(&mut self, val: usize, offset: usize) -> Result<()> { ... } fn write_usize_le(&mut self, val: usize, offset: usize) -> Result<()> { ... } fn write_u32(&mut self, val: u32, offset: usize) -> Result<()> { ... } fn write_u32_le(&mut self, val: u32, offset: usize) -> Result<()> { ... } fn write_u64(&mut self, val: u64, offset: usize) -> Result<()> { ... } fn write_u64_le(&mut self, val: u64, offset: usize) -> Result<()> { ... } fn write_u128(&mut self, val: u128, offset: usize) -> Result<()> { ... } fn write_u128_le(&mut self, val: u128, offset: usize) -> Result<()> { ... } fn write_f32(&mut self, val: f32, offset: usize) -> Result<()> { ... } fn write_f32_le(&mut self, val: f32, offset: usize) -> Result<()> { ... } fn write_f64(&mut self, val: f64, offset: usize) -> Result<()> { ... } fn write_f64_le(&mut self, val: f64, offset: usize) -> Result<()> { ... }
}
Available on crate features async-std and async-trait only.
Expand description

Utility methods to AsyncMmapFileMut

Required Methods§

source

fn as_mut_slice(&mut self) -> &mut [u8]

Returns the mutable underlying slice of the mmap

source

fn is_cow(&self) -> bool

Whether mmap is copy on write

source

fn flush(&self) -> Result<()>

Flushes outstanding memory map modifications to disk (if the inner is a real file).

When this method returns with a non-error result, all outstanding changes to a file-backed memory map are guaranteed to be durably stored. The file’s metadata (including last modification timestamp) may not be updated.

source

fn flush_async(&self) -> Result<()>

Asynchronously flushes outstanding memory map modifications to disk(if the inner is a real file).

This method initiates flushing modified pages to durable storage, but it will not wait for the operation to complete before returning. The file’s metadata (including last modification timestamp) may not be updated.

source

fn flush_range(&self, offset: usize, len: usize) -> Result<()>

Flushes outstanding memory map modifications in the range to disk(if the inner is a real file).

The offset and length must be in the bounds of the memory map.

When this method returns with a non-error result, all outstanding changes to a file-backed memory in the range are guaranteed to be durable stored. The file’s metadata (including last modification timestamp) may not be updated. It is not guaranteed the only the changes in the specified range are flushed; other outstanding changes to the memory map may be flushed as well.

source

fn flush_async_range(&self, offset: usize, len: usize) -> Result<()>

Asynchronously flushes outstanding memory map modifications in the range to disk(if the inner is a real file).

The offset and length must be in the bounds of the memory map.

This method initiates flushing modified pages to durable storage, but it will not wait for the operation to complete before returning. The file’s metadata (including last modification timestamp) may not be updated. It is not guaranteed that the only changes flushed are those in the specified range; other outstanding changes to the memory map may be flushed as well.

source

fn truncate<'life0, 'async_trait>( &'life0 mut self, max_sz: u64 ) -> Pin<Box<dyn Future<Output = Result<()>> + Send + 'async_trait>>where Self: 'async_trait, 'life0: 'async_trait,

Truncates the file to the max_size, which will lead to do re-mmap and sync_dir if the inner is a real file.

source

fn drop_remove<'async_trait>( self ) -> Pin<Box<dyn Future<Output = Result<()>> + Send + 'async_trait>>where Self: 'async_trait,

Remove the underlying file

source

fn close_with_truncate<'async_trait>( self, max_sz: i64 ) -> Pin<Box<dyn Future<Output = Result<()>> + Send + 'async_trait>>where Self: 'async_trait,

Close and truncate the underlying file

Provided Methods§

source

fn slice_mut(&mut self, offset: usize, sz: usize) -> &mut [u8]

slice_mut returns mutable data starting from offset off of size sz.

Panics

If there’s not enough data, it would panic.

source

fn bytes_mut(&mut self, offset: usize, sz: usize) -> Result<&mut [u8]>

bytes_mut returns mutable data starting from offset off of size sz.

Errors

If there’s not enough data, it would return Err(Error::from(ErrorKind::EOF)).

source

fn zero_range(&mut self, start: usize, end: usize)

Fill 0 to the specific range

source

fn writer(&mut self, offset: usize) -> Result<AsyncMmapFileWriter<'_>>

Returns a AsyncMmapFileWriter base on the given offset, which helps read or write data from mmap like a normal File.

Notes

If you use a writer to write data to mmap, there is no guarantee all data will be durably stored. So you need to call flush/flush_range/flush_async/flush_async_range in AsyncMmapFileMutExt to guarantee all data will be durably stored.

Errors

If there’s not enough data, it would return Err(Error::from(ErrorKind::EOF)).

source

fn range_writer( &mut self, offset: usize, len: usize ) -> Result<AsyncMmapFileWriter<'_>>

Returns a AsyncMmapFileWriter base on the given offset and len, which helps read or write data from mmap like a normal File.

Notes

If you use a writer to write data to mmap, there is no guarantee all data will be durably stored. So you need to call flush/flush_range/flush_async/flush_async_range in [MmapFileMutExt] to guarantee all data will be durably stored.

Errors

If there’s not enough data, it would return Err(Error::from(ErrorKind::EOF)).

source

fn write(&mut self, src: &[u8], offset: usize) -> usize

Write bytes to the mmap from the offset.

source

fn write_all(&mut self, src: &[u8], offset: usize) -> Result<()>

Write the all of bytes in src to the mmap from the offset.

source

fn write_i8(&mut self, val: i8, offset: usize) -> Result<()>

Writes a signed 8 bit integer to mmap from the offset.

source

fn write_i16(&mut self, val: i16, offset: usize) -> Result<()>

Writes a signed 16 bit integer to mmap from the offset in the big-endian byte order.

source

fn write_i16_le(&mut self, val: i16, offset: usize) -> Result<()>

Writes a signed 16 bit integer to mmap from the offset in the little-endian byte order.

source

fn write_isize(&mut self, val: isize, offset: usize) -> Result<()>

Writes a signed integer to mmap from the offset in the big-endian byte order.

source

fn write_isize_le(&mut self, val: isize, offset: usize) -> Result<()>

Writes a signed integer to mmap from the offset in the little-endian byte order.

source

fn write_i32(&mut self, val: i32, offset: usize) -> Result<()>

Writes a signed 32 bit integer to mmap from the offset in the big-endian byte order.

source

fn write_i32_le(&mut self, val: i32, offset: usize) -> Result<()>

Writes a signed 32 bit integer to mmap from the offset in the little-endian byte order.

source

fn write_i64(&mut self, val: i64, offset: usize) -> Result<()>

Writes a signed 64 bit integer to mmap from the offset in the big-endian byte order.

source

fn write_i64_le(&mut self, val: i64, offset: usize) -> Result<()>

Writes a signed 64 bit integer to mmap from the offset in the little-endian byte order.

source

fn write_i128(&mut self, val: i128, offset: usize) -> Result<()>

Writes a signed 128 bit integer to mmap from the offset in the big-endian byte order.

source

fn write_i128_le(&mut self, val: i128, offset: usize) -> Result<()>

Writes a signed 128 bit integer to mmap from the offset in the little-endian byte order.

source

fn write_u8(&mut self, val: u8, offset: usize) -> Result<()>

Writes an unsigned 8 bit integer to mmap from the offset.

source

fn write_u16(&mut self, val: u16, offset: usize) -> Result<()>

Writes an unsigned 16 bit integer to mmap from the offset in the big-endian byte order.

source

fn write_u16_le(&mut self, val: u16, offset: usize) -> Result<()>

Writes an unsigned 16 bit integer to mmap from the offset in the little-endian byte order.

source

fn write_usize(&mut self, val: usize, offset: usize) -> Result<()>

Writes an unsigned integer to mmap from the offset in the big-endian byte order.

source

fn write_usize_le(&mut self, val: usize, offset: usize) -> Result<()>

Writes an unsigned integer to mmap from the offset in the little-endian byte order.

source

fn write_u32(&mut self, val: u32, offset: usize) -> Result<()>

Writes an unsigned 32 bit integer to mmap from the offset in the big-endian byte order.

source

fn write_u32_le(&mut self, val: u32, offset: usize) -> Result<()>

Writes an unsigned 32 bit integer to mmap from the offset in the little-endian byte order.

source

fn write_u64(&mut self, val: u64, offset: usize) -> Result<()>

Writes an unsigned 64 bit integer to mmap from the offset in the big-endian byte order.

source

fn write_u64_le(&mut self, val: u64, offset: usize) -> Result<()>

Writes an unsigned 64 bit integer to mmap from the offset in the little-endian byte order.

source

fn write_u128(&mut self, val: u128, offset: usize) -> Result<()>

Writes an unsigned 128 bit integer to mmap from the offset in the big-endian byte order.

source

fn write_u128_le(&mut self, val: u128, offset: usize) -> Result<()>

Writes an unsigned 128 bit integer to mmap from the offset in the little-endian byte order.

source

fn write_f32(&mut self, val: f32, offset: usize) -> Result<()>

Writes an IEEE754 single-precision (4 bytes) floating point number to mmap from the offset in big-endian byte order.

source

fn write_f32_le(&mut self, val: f32, offset: usize) -> Result<()>

Writes an IEEE754 single-precision (4 bytes) floating point number to mmap from the offset in little-endian byte order.

source

fn write_f64(&mut self, val: f64, offset: usize) -> Result<()>

Writes an IEEE754 single-precision (8 bytes) floating point number to mmap from the offset in big-endian byte order.

source

fn write_f64_le(&mut self, val: f64, offset: usize) -> Result<()>

Writes an IEEE754 single-precision (8 bytes) floating point number to mmap from the offset in little-endian byte order.

Implementors§