[−][src]Struct grin_store::types::DataFile
Data file (MMR) wrapper around an append-only file.
Methods
impl<T> DataFile<T> where
T: Readable + Writeable + Debug,
[src]
T: Readable + Writeable + Debug,
pub fn open<P>(
path: P,
size_info: SizeInfo,
version: ProtocolVersion
) -> Result<DataFile<T>> where
P: AsRef<Path> + Debug,
[src]
path: P,
size_info: SizeInfo,
version: ProtocolVersion
) -> Result<DataFile<T>> where
P: AsRef<Path> + Debug,
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,
T: Send,
impl<T> Sync for DataFile<T> where
T: Sync,
T: Sync,
impl<T> Unpin for DataFile<T> where
T: Unpin,
T: Unpin,
impl<T> UnwindSafe for DataFile<T> where
T: UnwindSafe,
T: UnwindSafe,
impl<T> RefUnwindSafe for DataFile<T> where
T: RefUnwindSafe,
T: RefUnwindSafe,
Blanket Implementations
impl<T, U> Into<U> for T where
U: From<T>,
[src]
U: From<T>,
impl<T> From<T> for T
[src]
impl<T, U> TryFrom<U> for T where
U: Into<T>,
[src]
U: Into<T>,
type Error = Infallible
The type returned in the event of a conversion error.
fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>
[src]
impl<T, U> TryInto<U> for T where
U: TryFrom<T>,
[src]
U: TryFrom<T>,
type Error = <U as TryFrom<T>>::Error
The type returned in the event of a conversion error.
fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>
[src]
impl<T> Borrow<T> for T where
T: ?Sized,
[src]
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
[src]
T: ?Sized,
fn borrow_mut(&mut self) -> &mut T
[src]
impl<T> Any for T where
T: 'static + ?Sized,
[src]
T: 'static + ?Sized,
impl<T> UnsafeAny for T where
T: Any,
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,
T: ?Sized,
fn borrow_replacement(ptr: &T) -> &T
impl<V, T> VZip<V> for T where
V: MultiLane<T>,
V: MultiLane<T>,