Struct mmap_storage::file::Storage [−][src]
pub struct Storage { /* fields omitted */ }
File memory map backed storage.
Attempting to resize storage results in error.
Methods
impl Storage
[src]
impl Storage
pub fn open<P: AsRef<Path>>(path: P) -> Result<Self>
[src]
pub fn open<P: AsRef<Path>>(path: P) -> Result<Self>
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]
pub fn open_exising<P: AsRef<Path>>(path: P) -> Result<Self>
Opens storage, if it doesn't exist return error.
pub fn as_slice(&self) -> &[u8]
[src]
pub fn as_slice(&self) -> &[u8]
Returns slice with view on written data.
pub fn as_mut_slice(&mut self) -> &mut [u8]
[src]
pub fn as_mut_slice(&mut self) -> &mut [u8]
Returns slice with view on written data.
pub fn capacity(&self) -> usize
[src]
pub fn capacity(&self) -> usize
Returns overall size of storage(including extra space).
pub fn flush_async(&self) -> Result<()>
[src]
pub fn flush_async(&self) -> Result<()>
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]
pub fn flush_sync(&self) -> Result<()>
Synchronously flushes outstanding memory map modifications to disk.
pub fn resize(&mut self, new_size: usize) -> Result<()>
[src]
pub fn resize(&mut self, new_size: usize) -> Result<()>
Resizes storage by appending or truncating.
It modifies file size and re-mmaps file.
pub fn put_data(&mut self, data: &[u8]) -> Result<()>
[src]
pub fn put_data(&mut self, data: &[u8]) -> Result<()>
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]
pub fn extend_from_slice(&mut self, data: &[u8]) -> Result<()>
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]
pub fn copy_from_slice(&mut self, data: &[u8])
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]
pub fn to_vec(&self) -> Vec<u8>
Creates Vec
from content of storage.
Trait Implementations
impl Write for Storage
[src]
impl Write for Storage
fn write(&mut self, buf: &[u8]) -> Result<usize>
[src]
fn write(&mut self, buf: &[u8]) -> Result<usize>
Write a buffer into this object, returning how many bytes were written. Read more
fn write_all(&mut self, buf: &[u8]) -> Result<()>
[src]
fn write_all(&mut self, buf: &[u8]) -> Result<()>
Attempts to write an entire buffer into this write. Read more
fn flush(&mut self) -> Result<()>
[src]
fn flush(&mut self) -> Result<()>
Flush this output stream, ensuring that all intermediately buffered contents reach their destination. Read more
fn write_fmt(&mut self, fmt: Arguments) -> Result<(), Error>
1.0.0[src]
fn write_fmt(&mut self, fmt: Arguments) -> Result<(), Error>
Writes a formatted string into this writer, returning any error encountered. Read more
fn by_ref(&mut self) -> &mut Self
1.0.0[src]
fn by_ref(&mut self) -> &mut Self
Creates a "by reference" adaptor for this instance of Write
. Read more