Make store::Row sortable (by key) and clonable
This commit is contained in:
parent
baf2d8624d
commit
45f3c7d178
22
src/store.rs
22
src/store.rs
|
@ -1,10 +1,12 @@
|
|||
use rocksdb;
|
||||
use rocksdb::Writable;
|
||||
|
||||
use std::cmp::Ordering;
|
||||
use std::path::Path;
|
||||
|
||||
use util::Bytes;
|
||||
|
||||
#[derive(Clone)]
|
||||
pub struct Row {
|
||||
pub key: Bytes,
|
||||
pub value: Bytes,
|
||||
|
@ -16,6 +18,26 @@ impl Row {
|
|||
}
|
||||
}
|
||||
|
||||
impl Ord for Row {
|
||||
fn cmp(&self, other: &Row) -> Ordering {
|
||||
self.key.cmp(&other.key)
|
||||
}
|
||||
}
|
||||
|
||||
impl PartialOrd for Row {
|
||||
fn partial_cmp(&self, other: &Row) -> Option<Ordering> {
|
||||
Some(self.cmp(other))
|
||||
}
|
||||
}
|
||||
|
||||
impl PartialEq for Row {
|
||||
fn eq(&self, other: &Row) -> bool {
|
||||
self.key.eq(&other.key)
|
||||
}
|
||||
}
|
||||
|
||||
impl Eq for Row {}
|
||||
|
||||
pub trait ReadStore: Sync {
|
||||
fn get(&self, key: &[u8]) -> Option<Bytes>;
|
||||
fn scan(&self, prefix: &[u8]) -> Vec<Row>;
|
||||
|
|
Loading…
Reference in New Issue
Block a user