DiskMmapFileMut

Struct DiskMmapFileMut 

Source
pub struct DiskMmapFileMut { /* private fields */ }
Available on crate feature sync only.
Expand description

DiskMmapFile contains a mutable mmap buffer and a writable file.

Implementations§

Source§

impl DiskMmapFileMut

Source

pub fn create<P: AsRef<Path>>(path: P) -> Result<Self, Error>

Create a new file and mmap this file

§Notes

The new file is zero size, so before do write, you should truncate first. Or you can use create_with_options and set max_size field for Options to enable directly write without truncating.

§Examples
use fmmap::MmapFileMutExt;
use fmmap::raw::DiskMmapFileMut;

let mut file = DiskMmapFileMut::create("disk_create_test.txt").unwrap();
file.truncate(100);
file.write_all("some data...".as_bytes(), 0).unwrap();
file.flush().unwrap();
Source

pub fn create_with_options<P: AsRef<Path>>( path: P, opts: Options, ) -> Result<Self, Error>

Create a new file and mmap this file with Options

§Examples
use fmmap::{Options, MmapFileMutExt};
use fmmap::raw::DiskMmapFileMut;

let opts = Options::new()
    // truncate to 100
    .max_size(100);
let mut file = DiskMmapFileMut::create_with_options("disk_create_with_options_test.txt", opts).unwrap();
file.write_all("some data...".as_bytes(), 0).unwrap();
file.flush().unwrap();
Source

pub fn open<P: AsRef<Path>>(path: P) -> Result<Self, Error>

Open or Create(if not exists) a file and mmap this file.

§Notes

If the file does not exist, then the new file will be open in zero size, so before do write, you should truncate first. Or you can use open_with_options and set max_size field for Options to enable directly write without truncating.

§Examples

File already exists

use fmmap::{MmapFileExt, MmapFileMutExt};
use fmmap::raw::DiskMmapFileMut;
use std::fs::File;
use std::io::{Read, Write};


// open and mmap the file
let mut file = DiskMmapFileMut::open("disk_open_test.txt").unwrap();
let mut buf = vec![0; "some data...".len()];
file.read_exact(buf.as_mut_slice(), 0);
assert_eq!(buf.as_slice(), "some data...".as_bytes());

// modify the file data
file.truncate("some modified data...".len() as u64).unwrap();
file.write_all("some modified data...".as_bytes(), 0).unwrap();
file.flush().unwrap();
drop(file);

// reopen to check content
let mut buf = vec![0; "some modified data...".len()];
let mut file = File::open("disk_open_test.txt").unwrap();
file.read_exact(buf.as_mut_slice()).unwrap();
assert_eq!(buf.as_slice(), "some modified data...".as_bytes());

File does not exists

use fmmap::{MmapFileExt, MmapFileMutExt};
use fmmap::raw::DiskMmapFileMut;
use std::fs::File;
use std::io::{Read, Write};

// create and mmap the file
let mut file = DiskMmapFileMut::open("disk_open_test.txt").unwrap();
file.truncate(100).unwrap();
file.write_all("some data...".as_bytes(), 0).unwrap();

let mut buf = vec![0; "some data...".len()];
file.read_exact(buf.as_mut_slice(), 0);
assert_eq!(buf.as_slice(), "some data...".as_bytes());

// modify the file data
file.truncate("some modified data...".len() as u64).unwrap();
file.write_all("some modified data...".as_bytes(), 0).unwrap();
file.flush().unwrap();
drop(file);

// reopen to check content
let mut buf = vec![0; "some modified data...".len()];
let mut file = File::open("disk_open_test.txt").unwrap();
file.read_exact(buf.as_mut_slice()).unwrap();
assert_eq!(buf.as_slice(), "some modified data...".as_bytes());
Source

pub fn open_with_options<P: AsRef<Path>>( path: P, opts: Options, ) -> Result<Self, Error>

Open or Create(if not exists) a file and mmap this file with Options.

§Examples

File already exists

use fmmap::{MmapFileExt, MmapFileMutExt, Options};
use fmmap::raw::DiskMmapFileMut;
use std::fs::File;
use std::io::{Read, Seek, SeekFrom, Write};


// mmap the file with options
let opts = Options::new()
    // allow read
    .read(true)
    // allow write
    .write(true)
    // allow append
    .append(true)
    // truncate to 100
    .max_size(100)
    // mmap content after the sanity text
    .offset("sanity text".as_bytes().len() as u64);
let mut file = DiskMmapFileMut::open_with_options("disk_open_test_with_options.txt", opts).unwrap();
let mut buf = vec![0; "some data...".len()];
file.read_exact(buf.as_mut_slice(), 0);
assert_eq!(buf.as_slice(), "some data...".as_bytes());

// modify the file data
file.truncate(("some modified data...".len() + "sanity text".len()) as u64).unwrap();
file.write_all("some modified data...".as_bytes(), 0).unwrap();
file.flush().unwrap();
drop(file);

// reopen to check content
let mut buf = vec![0; "some modified data...".len()];
let mut file = File::open("disk_open_test_with_options.txt").unwrap();
file.seek(SeekFrom::Start("sanity text".as_bytes().len() as u64)).unwrap();
file.read_exact(buf.as_mut_slice()).unwrap();
assert_eq!(buf.as_slice(), "some modified data...".as_bytes());

File does not exists

use fmmap::{MmapFileExt, MmapFileMutExt, Options};
use fmmap::raw::DiskMmapFileMut;
use std::fs::File;
use std::io::{Read, Write};

// mmap the file with options
let opts = Options::new()
    // allow read
    .read(true)
    // allow write
    .write(true)
    // allow append
    .append(true)
    // truncate to 100
    .max_size(100);

let mut file = DiskMmapFileMut::open_with_options("disk_open_test_with_options.txt", opts).unwrap();
file.write_all("some data...".as_bytes(), 0).unwrap();

let mut buf = vec![0; "some data...".len()];
file.read_exact(buf.as_mut_slice(), 0);
assert_eq!(buf.as_slice(), "some data...".as_bytes());

// modify the file data
file.truncate("some modified data...".len() as u64).unwrap();
file.write_all("some modified data...".as_bytes(), 0).unwrap();
file.flush().unwrap();
drop(file);

// reopen to check content
let mut buf = vec![0; "some modified data...".len()];
let mut file = File::open("disk_open_test_with_options.txt").unwrap();
file.read_exact(buf.as_mut_slice()).unwrap();
assert_eq!(buf.as_slice(), "some modified data...".as_bytes());
Source

pub fn open_exist<P: AsRef<Path>>(path: P) -> Result<Self, Error>

Open an existing file and mmap this file

§Examples
use fmmap::{MmapFileExt, MmapFileMutExt};
use fmmap::raw::DiskMmapFileMut;
use std::fs::File;
use std::io::{Read, Write};

// create a temp file
let mut file = File::create("disk_open_existing_test.txt").unwrap();
file.write_all("some data...".as_bytes()).unwrap();
drop(file);

// mmap the file
let mut file = DiskMmapFileMut::open_exist("disk_open_existing_test.txt").unwrap();
let mut buf = vec![0; "some data...".len()];
file.read_exact(buf.as_mut_slice(), 0);
assert_eq!(buf.as_slice(), "some data...".as_bytes());

// modify the file data
file.truncate("some modified data...".len() as u64).unwrap();
file.write_all("some modified data...".as_bytes(), 0).unwrap();
file.flush().unwrap();
drop(file);

// reopen to check content
let mut buf = vec![0; "some modified data...".len()];
let mut file = File::open("disk_open_existing_test.txt").unwrap();
file.read_exact(buf.as_mut_slice()).unwrap();
assert_eq!(buf.as_slice(), "some modified data...".as_bytes());
Source

pub fn open_exist_with_options<P: AsRef<Path>>( path: P, opts: Options, ) -> Result<Self, Error>

Open an existing file and mmap this file with Options

§Examples
use fmmap::{MmapFileExt, MmapFileMutExt, Options};
use fmmap::raw::DiskMmapFileMut;
use std::fs::File;
use std::io::{Read, Seek, SeekFrom, Write};

// create a temp file
let mut file = File::create("disk_open_existing_test_with_options.txt").unwrap();
file.write_all("sanity text".as_bytes()).unwrap();
file.write_all("some data...".as_bytes()).unwrap();
drop(file);

// mmap the file with options
let opts = Options::new()
    // truncate to 100
    .max_size(100)
    // mmap content after the sanity text
    .offset("sanity text".as_bytes().len() as u64);
let mut file = DiskMmapFileMut::open_exist_with_options("disk_open_existing_test_with_options.txt", opts).unwrap();
let mut buf = vec![0; "some data...".len()];
file.read_exact(buf.as_mut_slice(), 0);
assert_eq!(buf.as_slice(), "some data...".as_bytes());

// modify the file data
file.truncate(("some modified data...".len() + "sanity text".len()) as u64).unwrap();
file.write_all("some modified data...".as_bytes(), 0).unwrap();
file.flush().unwrap();
drop(file);

// reopen to check content
let mut buf = vec![0; "some modified data...".len()];
let mut file = File::open("disk_open_existing_test_with_options.txt").unwrap();
file.seek(SeekFrom::Start("sanity text".as_bytes().len() as u64)).unwrap();
file.read_exact(buf.as_mut_slice()).unwrap();
assert_eq!(buf.as_slice(), "some modified data...".as_bytes());
Source

pub fn open_cow<P: AsRef<Path>>(path: P) -> Result<Self, Error>

Open and mmap an existing file in copy-on-write mode(copy-on-write memory map backed by a file). Data written to the memory map will not be visible by other processes, and will not be carried through to the underlying file.

§Examples
use fmmap::{MmapFileExt, MmapFileMutExt};
use fmmap::raw::DiskMmapFileMut;
use std::fs::File;
use std::io::{Read, Write};

// create a temp file
let mut file = File::create("disk_open_cow_test.txt").unwrap();
file.write_all("some data...".as_bytes()).unwrap();
drop(file);

// mmap the file
let mut file = DiskMmapFileMut::open_cow("disk_open_cow_test.txt").unwrap();
let mut buf = vec![0; "some data...".len()];
file.read_exact(buf.as_mut_slice(), 0).unwrap();
assert_eq!(buf.as_slice(), "some data...".as_bytes());

// modify the file data
file.write_all("some data!!!".as_bytes(), 0).unwrap();
file.flush().unwrap();

// cow, change will only be seen in current caller
assert_eq!(file.as_slice(), "some data!!!".as_bytes());
drop(file);

// reopen to check content, cow will not change the content.
let mut file = File::open("disk_open_cow_test.txt").unwrap();
let mut buf = vec![0; "some data...".len()];
file.read_exact(buf.as_mut_slice()).unwrap();
assert_eq!(buf.as_slice(), "some data...".as_bytes());
Source

pub fn open_cow_with_options<P: AsRef<Path>>( path: P, opts: Options, ) -> Result<Self, Error>

Open and mmap an existing file in copy-on-write mode(copy-on-write memory map backed by a file) with Options. Data written to the memory map will not be visible by other processes, and will not be carried through to the underlying file.

§Examples
use fmmap::{MmapFileExt, MmapFileMutExt, Options};
use fmmap::raw::DiskMmapFileMut;
use std::fs::File;
use std::io::{Read, Seek, Write, SeekFrom};

// create a temp file
let mut file = File::create("disk_open_cow_with_options_test.txt").unwrap();
file.write_all("sanity text".as_bytes()).unwrap();
file.write_all("some data...".as_bytes()).unwrap();
drop(file);

// mmap the file with options
let opts = Options::new()
    // mmap content after the sanity text
    .offset("sanity text".as_bytes().len() as u64);
let mut file = DiskMmapFileMut::open_cow_with_options("disk_open_cow_with_options_test.txt", opts).unwrap();
let mut buf = vec![0; "some data...".len()];
file.read_exact(buf.as_mut_slice(), 0).unwrap();
assert_eq!(buf.as_slice(), "some data...".as_bytes());

// modify the file data
file.write_all("some data!!!".as_bytes(), 0).unwrap();
file.flush().unwrap();

// cow, change will only be seen in current caller
assert_eq!(file.as_slice(), "some data!!!".as_bytes());
drop(file);

// reopen to check content, cow will not change the content.
let mut file = File::open("disk_open_cow_with_options_test.txt").unwrap();
let mut buf = vec![0; "some data...".len()];
// skip the sanity text
file.seek(SeekFrom::Start("sanity text".as_bytes().len() as u64)).unwrap();
file.read_exact(buf.as_mut_slice()).unwrap();
assert_eq!(buf.as_slice(), "some data...".as_bytes());
Source

pub fn freeze(self) -> Result<DiskMmapFile, Error>

Returns an immutable version of this memory mapped buffer. If the memory map is file-backed, the file must have been opened with read permissions.

§Errors

This method returns an error when the underlying system call fails, which can happen for a variety of reasons, such as when the file has not been opened with read permissions.

§Examples
use fmmap::MmapFileMutExt;
use fmmap::raw::DiskMmapFileMut;

let mut file = DiskMmapFileMut::create("disk_mmap_file_freeze_test.txt").unwrap();
file.truncate(12);
file.write_all("some data...".as_bytes(), 0).unwrap();
file.flush().unwrap();

file.freeze().unwrap();
Source

pub fn freeze_exec(self) -> Result<DiskMmapFile, Error>

Transition the memory map to be readable and executable. If the memory map is file-backed, the file must have been opened with execute permissions.

§Errors

This method returns an error when the underlying system call fails, which can happen for a variety of reasons, such as when the file has not been opened with execute permissions

§Examples
use fmmap::MmapFileMutExt;
use fmmap::raw::DiskMmapFileMut;

let mut file = DiskMmapFileMut::create("disk_mmap_file_freeze_test.txt").unwrap();
file.truncate(12);
file.write_all("some data...".as_bytes(), 0).unwrap();
file.flush().unwrap();

file.freeze_exec().unwrap();

Trait Implementations§

Source§

impl From<DiskMmapFileMut> for MmapFileMut

Source§

fn from(file: DiskMmapFileMut) -> Self

Converts to this type from the input type.
Source§

impl MmapFileExt for DiskMmapFileMut

Source§

fn is_exec(&self) -> bool

Whether the mmap is executable.

Source§

fn len(&self) -> usize

Returns the current mmap length
Source§

fn as_slice(&self) -> &[u8]

Returns the underlying slice of the mmap
Source§

fn path(&self) -> &Path

Returns the path of the inner file.
Source§

fn metadata(&self) -> Result<MetaData>

Returns the metadata of file metadata Read more
Source§

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

Locks the file for exclusively usage, blocking if the file is currently locked. Read more
Source§

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

Locks the file for shared usage, blocking if the file is currently locked exclusively. Read more
Source§

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

Locks the file for exclusively usage, or returns a an error if the file is currently locked (see lock_contended_error). Read more
Source§

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

Locks the file for shared usage, or returns a an error if the file is currently locked exclusively (see lock_contended_error). Read more
Source§

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

Unlocks the file. Read more
Source§

fn is_empty(&self) -> bool

Returns the mmap is empty of not.
Source§

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

slice returns data starting from offset off of size sz. Read more
Source§

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

bytes returns data starting from offset off of size sz. Read more
Source§

fn path_buf(&self) -> PathBuf

Returns the path buf of the inner file.
Source§

fn path_lossy(&self) -> Cow<'_, str>

Returns the path lossy string of the inner file.
Source§

fn path_string(&self) -> String

Returns the path string of the inner file.
Source§

fn copy_all_to_vec(&self) -> Vec<u8>

Copy the content of the mmap file to Vec
Source§

fn copy_range_to_vec(&self, offset: usize, len: usize) -> Vec<u8>

Copy a range of content of the mmap file to Vec
Source§

fn write_all_to_new_file<P: AsRef<Path>>(&self, new_file_path: P) -> Result<()>

Write the content of the mmap file to a new file.
Source§

fn write_range_to_new_file<P: AsRef<Path>>( &self, new_file_path: P, offset: usize, len: usize, ) -> Result<()>

Write a range of content of the mmap file to new file.
Source§

fn reader(&self, offset: usize) -> Result<MmapFileReader<'_>>

Returns a MmapFileReader which helps read data from mmap like a normal File. Read more
Source§

fn range_reader(&self, offset: usize, len: usize) -> Result<MmapFileReader<'_>>

Returns a MmapFileReader base on the given offset and len, which helps read data from mmap like a normal File. Read more
Source§

fn read(&self, dst: &mut [u8], offset: usize) -> usize

Read bytes to the dst buf from the offset, returns how many bytes read.
Source§

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

Read the exact number of bytes required to fill buf.
Source§

fn read_i8(&self, offset: usize) -> Result<i8>

Read a signed 8 bit integer from offset.
Source§

fn read_i16(&self, offset: usize) -> Result<i16>

Read a signed 16 bit integer from offset in big-endian byte order.
Source§

fn read_i16_le(&self, offset: usize) -> Result<i16>

Read a signed 16 bit integer from offset in little-endian byte order.
Source§

fn read_isize(&self, offset: usize) -> Result<isize>

Read a signed integer from offset in big-endian byte order.
Source§

fn read_isize_le(&self, offset: usize) -> Result<isize>

Read a signed integer from offset in little-endian byte order.
Source§

fn read_i32(&self, offset: usize) -> Result<i32>

Read a signed 32 bit integer from offset in big-endian byte order.
Source§

fn read_i32_le(&self, offset: usize) -> Result<i32>

Read a signed 32 bit integer from offset in little-endian byte order.
Source§

fn read_i64(&self, offset: usize) -> Result<i64>

Read a signed 64 bit integer from offset in big-endian byte order.
Source§

fn read_i64_le(&self, offset: usize) -> Result<i64>

Read a signed 64 bit integer from offset in little-endian byte order.
Source§

fn read_i128(&self, offset: usize) -> Result<i128>

Read a signed 128 bit integer from offset in big-endian byte order.
Source§

fn read_i128_le(&self, offset: usize) -> Result<i128>

Read a signed 128 bit integer from offset in little-endian byte order.
Source§

fn read_u8(&self, offset: usize) -> Result<u8>

Read an unsigned 8 bit integer from offset.
Source§

fn read_u16(&self, offset: usize) -> Result<u16>

Read an unsigned 16 bit integer from offset in big-endian.
Source§

fn read_u16_le(&self, offset: usize) -> Result<u16>

Read an unsigned 16 bit integer from offset in little-endian.
Source§

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

Read an unsigned integer from offset in big-endian byte order.
Source§

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

Read an unsigned integer from offset in little-endian byte order.
Source§

fn read_u32(&self, offset: usize) -> Result<u32>

Read an unsigned 32 bit integer from offset in big-endian.
Source§

fn read_u32_le(&self, offset: usize) -> Result<u32>

Read an unsigned 32 bit integer from offset in little-endian.
Source§

fn read_u64(&self, offset: usize) -> Result<u64>

Read an unsigned 64 bit integer from offset in big-endian.
Source§

fn read_u64_le(&self, offset: usize) -> Result<u64>

Read an unsigned 64 bit integer from offset in little-endian.
Source§

fn read_u128(&self, offset: usize) -> Result<u128>

Read an unsigned 128 bit integer from offset in big-endian.
Source§

fn read_u128_le(&self, offset: usize) -> Result<u128>

Read an unsigned 128 bit integer from offset in little-endian.
Source§

fn read_f32(&self, offset: usize) -> Result<f32>

Read an IEEE754 single-precision (4 bytes) floating point number from offset in big-endian byte order.
Source§

fn read_f32_le(&self, offset: usize) -> Result<f32>

Read an IEEE754 single-precision (4 bytes) floating point number from offset in little-endian byte order.
Source§

fn read_f64(&self, offset: usize) -> Result<f64>

Read an IEEE754 single-precision (8 bytes) floating point number from offset in big-endian byte order.
Source§

fn read_f64_le(&self, offset: usize) -> Result<f64>

Read an IEEE754 single-precision (8 bytes) floating point number from offset in little-endian byte order.
Source§

impl MmapFileMutExt for DiskMmapFileMut

Source§

fn drop_remove(self) -> Result<()>

Remove the underlying file

§Examples
use fmmap::MmapFileMutExt;
use fmmap::raw::DiskMmapFileMut;

let mut file = DiskMmapFileMut::create("disk_remove_test.txt").unwrap();

file.truncate(100);
file.write_all("some data...".as_bytes(), 0).unwrap();
file.flush().unwrap();

file.remove().unwrap();

let err = std::fs::File::open("disk_remove_test.txt");
assert_eq!(err.unwrap_err().kind(), std::io::ErrorKind::NotFound);
Source§

fn close_with_truncate(self, max_sz: i64) -> Result<()>

Close and truncate the underlying file

§Examples
use fmmap::{MetaDataExt, MmapFileExt, MmapFileMutExt};
use fmmap::raw::DiskMmapFileMut;

let mut file = DiskMmapFileMut::create("disk_close_with_truncate_test.txt").unwrap();
file.truncate(100);
file.write_all("some data...".as_bytes(), 0).unwrap();
file.flush().unwrap();

file.close_with_truncate(50).unwrap();

let file = DiskMmapFileMut::open("disk_close_with_truncate_test.txt").unwrap();
let meta = file.metadata().unwrap();
assert_eq!(meta.len(), 50);
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). Read more
Source§

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

Asynchronously flushes outstanding memory map modifications to disk(if the inner is a real file). Read more
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). Read more
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). Read more
Source§

fn truncate(&mut self, max_sz: u64) -> Result<(), Error>

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 slice_mut(&mut self, offset: usize, sz: usize) -> &mut [u8]

slice_mut returns mutable data starting from offset off of size sz. Read more
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. Read more
Source§

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

Fill 0 to the specific range
Source§

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

Returns a MmapFileWriter base on the given offset, which helps read or write data from mmap like a normal File. Read more
Source§

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

Returns a MmapFileWriter base on the given offset and len, which helps read or write data from mmap like a normal File. Read more
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.

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> 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> IntoResult<T> for T

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.