[][src]Struct grin_store::types::DataFile

pub struct DataFile<T> { /* fields omitted */ }

Data file (MMR) wrapper around an append-only file.

Methods

impl<T> DataFile<T> where
    T: Readable + Writeable + Debug
[src]

pub fn open<P>(
    path: P,
    size_info: SizeInfo,
    version: ProtocolVersion
) -> Result<DataFile<T>> where
    P: AsRef<Path> + Debug
[src]

Open (or create) a file at the provided path on disk.

pub fn append(&mut self, data: &T) -> Result<u64>[src]

Append an element to the file. Will not be written to disk until flush() is subsequently called. Alternatively discard() may be called to discard any pending changes.

pub fn read(&self, position: u64) -> Option<T>[src]

Read an element from the file by position. Assumes we have already "shifted" the position to account for pruned data. Note: PMMR API is 1-indexed, but backend storage is 0-indexed.

Makes no assumptions about the size of the elements in bytes. Elements can be of variable size (handled internally in the append-only file impl).

pub fn rewind(&mut self, position: u64)[src]

Rewind the backend file to the specified position.

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

Flush unsynced changes to the file to disk.

pub fn discard(&mut self)[src]

Discard any unsynced changes to the file.

pub fn size(&self) -> u64[src]

Size of the file in number of elements (not bytes).

pub fn path(&self) -> &Path[src]

Path of the underlying file

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

Create a new tempfile containing the contents of this data file. This allows callers to see a consistent view of the data without locking the data file.

pub fn release(&mut self)[src]

Drop underlying file handles

pub fn save_prune(&mut self, prune_pos: &[u64]) -> Result<()>[src]

Write the file out to disk, pruning removed elements.

Auto Trait Implementations

impl<T> Send for DataFile<T> where
    T: Send

impl<T> Sync for DataFile<T> where
    T: Sync

impl<T> Unpin for DataFile<T> where
    T: Unpin

impl<T> UnwindSafe for DataFile<T> where
    T: UnwindSafe

impl<T> RefUnwindSafe for DataFile<T> where
    T: RefUnwindSafe

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> Borrow<T> for T where
    T: ?Sized
[src]

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

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

impl<T> UnsafeAny for T where
    T: Any

impl<T> Same<T> for T

type Output = T

Should always be Self

impl<T> Erased for T

impl<T> SafeBorrow<T> for T where
    T: ?Sized

impl<V, T> VZip<V> for T where
    V: MultiLane<T>,