pub trait MmapFileMutExt {
Show 42 methods fn as_mut_slice(&mut self) -> &mut [u8]Notable traits for &[u8]impl<'_> Read for &[u8]impl<'_> Write for &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(&mut self, max_sz: u64) -> Result<()>; fn remove(self) -> Result<()>; fn close_with_truncate(self, max_sz: i64) -> Result<()>; fn slice_mut(&mut self, offset: usize, sz: usize) -> &mut [u8]Notable traits for &[u8]impl<'_> Read for &[u8]impl<'_> Write for &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<MmapFileWriter<'_>> { ... } fn range_writer(
        &mut self,
        offset: usize,
        len: usize
    ) -> Result<MmapFileWriter<'_>> { ... } 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<()> { ... }
}
Expand description

Utility methods to MmapFileMut

Required Methods

Returns the mutable underlying slice of the mmap

Whether mmap is copy on write

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.

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.

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.

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.

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

Remove the underlying file

Close and truncate the underlying file

Provided Methods

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

Panics

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

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)).

Fill 0 to the specific range

Returns a MmapFileWriter 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 MmapFileMutExt to guarantee all data will be durably stored.

Errors

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

Returns a MmapFileWriter 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)).

Write bytes to the mmap from the offset.

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

Implementors