pub struct DataStore { /* private fields */ }Implementations§
Source§impl DataStore
impl DataStore
Sourcepub fn create(path: &Path) -> IsamResult<Self>
pub fn create(path: &Path) -> IsamResult<Self>
Create a new, empty .idb file, truncating any existing one.
Sourcepub fn open(path: &Path) -> IsamResult<Self>
pub fn open(path: &Path) -> IsamResult<Self>
Open an existing .idb file for reading and appending.
Sourcepub fn append<K, V>(&mut self, key: &K, value: &V) -> IsamResult<RecordRef>
pub fn append<K, V>(&mut self, key: &K, value: &V) -> IsamResult<RecordRef>
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.
Sourcepub fn append_tombstone<K>(&mut self, key: &K) -> IsamResult<()>where
K: Serialize,
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.
Sourcepub fn read_value<V>(&mut self, rec: RecordRef) -> IsamResult<V>where
V: DeserializeOwned,
pub fn read_value<V>(&mut self, rec: RecordRef) -> IsamResult<V>where
V: DeserializeOwned,
Read and deserialize the value portion of the record at rec.
&mut self because Seek requires mutability on the file handle.
Sourcepub fn read_record_raw(
&mut self,
offset: u64,
) -> IsamResult<(u8, Vec<u8>, Vec<u8>)>
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).
Sourcepub fn write_raw_record(
&mut self,
status: u8,
key_bytes: &[u8],
val_bytes: &[u8],
) -> IsamResult<RecordRef>
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).
Sourcepub fn flush(&mut self) -> IsamResult<()>
pub fn flush(&mut self) -> IsamResult<()>
Flush OS buffers to disk.
Sourcepub fn fsync(&mut self) -> IsamResult<()>
pub fn fsync(&mut self) -> IsamResult<()>
Flush OS buffers and call fsync to ensure durability.