Expand index trait to also include key type

Signed-off-by: Lee Smet <lee.smet@hotmail.com>
This commit is contained in:
Lee Smet
2025-04-23 15:09:54 +02:00
parent 276cf3c8d8
commit 1343e61e0f
5 changed files with 75 additions and 58 deletions

View File

@@ -22,7 +22,7 @@ where
type Error: std::fmt::Debug;
/// Get all items where the given index field is equal to key.
fn get<I>(&self, key: K) -> Result<Vec<V>, Error<Self::Error>>
fn get<I>(&self, key: &I::Key) -> Result<Vec<V>, Error<Self::Error>>
where
I: Index<Model = V>;
@@ -33,7 +33,7 @@ where
fn set(&self, value: &V) -> Result<(), Error<Self::Error>>;
/// Delete all items from the db with a given index.
fn delete<I>(&self, key: K) -> Result<(), Error<Self::Error>>
fn delete<I>(&self, key: &I::Key) -> Result<(), Error<Self::Error>>
where
I: Index<Model = V>;
@@ -66,4 +66,3 @@ impl<E> From<bincode::error::EncodeError> for Error<E> {
Error::Encode(value)
}
}