move my_bucket out of trait
@@ -28,15 +28,12 @@ pub trait Storage {
&self,
id: &T,
) -> Result<Option<U>, Error>;
- /// Insert a value under the given key.
+ /// Insert a value under the given key. Will overwrite the existing value.
fn insert<T: Serialize, U: Serialize + DeserializeOwned>(
&self,
id: &T,
item: &U,
) -> Result<(), Error>;
- /// Return the bucket identifier that the Storage was instantiated with (this is
- /// to allow multiple processes to use the same underlying store).
- fn my_bucket(&self) -> u8;
}
pub struct RocksStorage {
@@ -51,6 +48,9 @@ impl RocksStorage {
bucket,
}
}
+ fn my_bucket(&self) -> u8 {
+ self.bucket
+ }
}
fn prefix_with_bucket(typ: u8, input: &[u8]) -> Vec<u8> {
@@ -83,9 +83,6 @@ impl Storage for RocksStorage {
&serde_json::to_vec(&item)?,
)?)
}
- fn my_bucket(&self) -> u8 {
- self.bucket
- }
}
