aboutsummaryrefslogtreecommitdiff
path: root/src/table/schema.rs
diff options
context:
space:
mode:
Diffstat (limited to 'src/table/schema.rs')
-rw-r--r--src/table/schema.rs18
1 files changed, 5 insertions, 13 deletions
diff --git a/src/table/schema.rs b/src/table/schema.rs
index 7daf3000..fc1a465e 100644
--- a/src/table/schema.rs
+++ b/src/table/schema.rs
@@ -1,5 +1,3 @@
-use std::borrow::Cow;
-
use serde::{Deserialize, Serialize};
use garage_db as db;
@@ -38,24 +36,18 @@ impl PartitionKey for FixedBytes32 {
/// Trait for field used to sort data
pub trait SortKey: Clone + Serialize + for<'de> Deserialize<'de> + Send + Sync + 'static {
/// Get the key used to sort
- fn sort_key(&self) -> Cow<'_, [u8]>;
+ fn sort_key(&self) -> &[u8];
}
impl SortKey for String {
- fn sort_key(&self) -> Cow<'_, [u8]> {
- Cow::from(self.as_bytes())
+ fn sort_key(&self) -> &[u8] {
+ self.as_bytes()
}
}
impl SortKey for FixedBytes32 {
- fn sort_key(&self) -> Cow<'_, [u8]> {
- Cow::from(self.as_slice())
- }
-}
-
-impl SortKey for u32 {
- fn sort_key(&self) -> Cow<'_, [u8]> {
- Cow::from(u32::to_be_bytes(*self).to_vec())
+ fn sort_key(&self) -> &[u8] {
+ self.as_slice()
}
}