pub trait StoreEngine:
Send
+ Sync
+ 'static {
// Required methods
fn put_batch(&self, kvs: &[(Bytes, Bytes)]) -> Result<u64, String>;
fn get(&self, key: &[u8]) -> Result<Option<Vec<u8>>, String>;
fn range_scan(
&self,
start: &[u8],
end: &[u8],
limit: usize,
forward: bool,
) -> Result<Vec<(Bytes, Bytes)>, String>;
fn delete_batch(&self, keys: &[&[u8]]) -> Result<u64, String>;
fn current_sequence(&self) -> u64;
// Provided method
fn get_many(
&self,
keys: &[&[u8]],
) -> Result<Vec<(Vec<u8>, Option<Vec<u8>>)>, String> { ... }
}Expand description
Implement these operations for your store. All methods must be thread-safe.
Required Methods§
Sourcefn put_batch(&self, kvs: &[(Bytes, Bytes)]) -> Result<u64, String>
fn put_batch(&self, kvs: &[(Bytes, Bytes)]) -> Result<u64, String>
Persist key-value pairs atomically and return the new global sequence number for this write.
Sourcefn get(&self, key: &[u8]) -> Result<Option<Vec<u8>>, String>
fn get(&self, key: &[u8]) -> Result<Option<Vec<u8>>, String>
Fetch the value for a single key. Returns None when the key does not exist.
Sourcefn range_scan(
&self,
start: &[u8],
end: &[u8],
limit: usize,
forward: bool,
) -> Result<Vec<(Bytes, Bytes)>, String>
fn range_scan( &self, start: &[u8], end: &[u8], limit: usize, forward: bool, ) -> Result<Vec<(Bytes, Bytes)>, String>
Keys in [start, end] (inclusive) when end is non-empty; empty end means unbounded
above. Matches store.query.v1.RangeRequest / ReduceRequest on the wire. limit caps
rows returned.
Sourcefn delete_batch(&self, keys: &[&[u8]]) -> Result<u64, String>
fn delete_batch(&self, keys: &[&[u8]]) -> Result<u64, String>
Delete a batch of keys atomically. Returns the new global sequence number.
Sourcefn current_sequence(&self) -> u64
fn current_sequence(&self) -> u64
Current sequence number visible to readers (used for min_sequence_number checks).