aboutsummaryrefslogtreecommitdiff
path: root/src/table/schema.rs
diff options
context:
space:
mode:
authorAlex Auvolat <alex@adnab.me>2023-01-05 13:11:48 +0100
committerAlex Auvolat <alex@adnab.me>2023-01-05 13:11:48 +0100
commit49b5d18554c67b84777d97f24423207c2375ae5e (patch)
tree70403f9899d8d47897e766fed6171f06ed047b35 /src/table/schema.rs
parent02e8eb167efa1f08d69fe7f8e6192cde726c45aa (diff)
downloadgarage-49b5d18554c67b84777d97f24423207c2375ae5e.tar.gz
garage-49b5d18554c67b84777d97f24423207c2375ae5e.zip
K2V history and preparation for range watch
Diffstat (limited to 'src/table/schema.rs')
-rw-r--r--src/table/schema.rs8
1 files changed, 7 insertions, 1 deletions
diff --git a/src/table/schema.rs b/src/table/schema.rs
index 5cbf6c95..86ff816a 100644
--- a/src/table/schema.rs
+++ b/src/table/schema.rs
@@ -31,17 +31,23 @@ impl PartitionKey for FixedBytes32 {
/// Trait for field used to sort data
pub trait SortKey: Clone + Serialize + for<'de> Deserialize<'de> + Send + Sync + 'static {
+ type B<'a>: std::borrow::Borrow<[u8]>;
+
/// Get the key used to sort
- fn sort_key(&self) -> &[u8];
+ fn sort_key(&self) -> Self::B<'_>;
}
impl SortKey for String {
+ type B<'a> = &'a [u8];
+
fn sort_key(&self) -> &[u8] {
self.as_bytes()
}
}
impl SortKey for FixedBytes32 {
+ type B<'a> = &'a [u8];
+
fn sort_key(&self) -> &[u8] {
self.as_slice()
}