[][src]Struct mmap_storage::file::Storage

pub struct Storage { /* fields omitted */ }

File memory map backed storage.

Attempting to resize storage results in error.

Methods

impl Storage[src]

pub fn open<P: AsRef<Path>>(path: P) -> Result<Self>[src]

Creates storage by opening or creating file at the specified location.

If file is newly created it is appended dummy byte.

pub fn open_exising<P: AsRef<Path>>(path: P) -> Result<Self>[src]

Opens storage, if it doesn't exist return error.

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

Returns slice with view on written data.

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

Returns slice with view on written data.

pub fn capacity(&self) -> usize[src]

Returns overall size of storage(including extra space).

pub fn flush_async(&self) -> Result<()>[src]

Asynchronously flushes outstanding memory map modifications to disk.

This method initiates flushing modified pages to durable storage, but it will not wait for the operation to complete before returning.

pub fn flush_sync(&self) -> Result<()>[src]

Synchronously flushes outstanding memory map modifications to disk.

pub fn resize(&mut self, new_size: usize) -> Result<()>[src]

Resizes storage by appending or truncating.

It modifies file size and re-mmaps file. When Attempting to set size to 0, the actual size will become 1.

If current cursor of data becomes out of actual file storage, it is shifted to actual file storage size

pub fn put_data(&mut self, data: &[u8]) -> Result<()>[src]

Resizes map accordingly to data and copies it.

Convenience method to map buffer to file.

pub fn extend_from_slice(&mut self, data: &[u8]) -> Result<()>[src]

Appends data to storage

Note that it resizes storage if needed. Therefore error can happen.

pub fn copy_from_slice(&mut self, data: &[u8])[src]

Copies data from slice into storage.

Function panics if data has greater len.

Note: It copies data up to storage capacity.

pub fn to_vec(&self) -> Vec<u8>[src]

Creates Vec from content of storage.

Trait Implementations

impl Write for Storage[src]

fn write_vectored(&mut self, bufs: &[IoSlice]) -> Result<usize, Error>1.36.0[src]

Like write, except that it writes from a slice of buffers. Read more

fn write_fmt(&mut self, fmt: Arguments) -> Result<(), Error>1.0.0[src]

Writes a formatted string into this writer, returning any error encountered. Read more

fn by_ref(&mut self) -> &mut Self1.0.0[src]

Creates a "by reference" adaptor for this instance of Write. Read more

Auto Trait Implementations

impl Sync for Storage

impl Unpin for Storage

impl Send for Storage

impl RefUnwindSafe for Storage

impl UnwindSafe for Storage

Blanket Implementations

impl<T, U> Into<U> for T where
    U: From<T>, 
[src]

impl<T> From<T> for T[src]

impl<T, U> TryFrom<U> for T where
    U: Into<T>, 
[src]

type Error = Infallible

The type returned in the event of a conversion error.

impl<T, U> TryInto<U> for T where
    U: TryFrom<T>, 
[src]

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.

impl<T> BorrowMut<T> for T where
    T: ?Sized
[src]

impl<T> Borrow<T> for T where
    T: ?Sized
[src]

impl<T> Any for T where
    T: 'static + ?Sized
[src]