DataStore

Struct DataStore 

Source
pub struct DataStore { /* private fields */ }

Implementations§

Source§

impl DataStore

Source

pub fn create(path: &Path) -> IsamResult<Self>

Create a new, empty .idb file, truncating any existing one.

Source

pub fn open(path: &Path) -> IsamResult<Self>

Open an existing .idb file for reading and appending.

Source

pub fn append<K, V>(&mut self, key: &K, value: &V) -> IsamResult<RecordRef>
where K: Serialize, V: Serialize,

Append a live record to the file.

Returns a RecordRef containing the byte offset and length so the B-tree index can locate this record later.

Source

pub fn append_tombstone<K>(&mut self, key: &K) -> IsamResult<()>
where K: Serialize,

Append a tombstone record for key.

The value portion is zero bytes; the B-tree entry will be removed separately, so tombstones in the data file are only needed for compaction safety.

Source

pub fn read_value<V>(&mut self, rec: RecordRef) -> IsamResult<V>

Read and deserialize the value portion of the record at rec.

&mut self because Seek requires mutability on the file handle.

Source

pub fn read_record_raw( &mut self, offset: u64, ) -> IsamResult<(u8, Vec<u8>, Vec<u8>)>

Read the raw bytes of a record (for use during compaction).

Returns (status, key_bytes, val_bytes).

Source

pub fn write_raw_record( &mut self, status: u8, key_bytes: &[u8], val_bytes: &[u8], ) -> IsamResult<RecordRef>

Write a raw pre-encoded record directly (used during compaction to copy records without re-serializing).

Source

pub fn flush(&mut self) -> IsamResult<()>

Flush OS buffers to disk.

Source

pub fn fsync(&mut self) -> IsamResult<()>

Flush OS buffers and call fsync to ensure durability.

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, 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.