diff --git a/database/src/key.rs b/database/src/key.rs index c0fee09d..69beff0d 100644 --- a/database/src/key.rs +++ b/database/src/key.rs @@ -4,6 +4,8 @@ #[allow(unused_imports)] // docs use crate::table::Table; +use crate::pod::Pod; + //---------------------------------------------------------------------------------------------------- Table /// Database [`Table`] key metadata. /// @@ -18,14 +20,28 @@ pub trait Key { /// will just be the same type as [`Key::Primary`]. const DUPLICATE: bool; - /// The primary key type. - type Primary; + // TODO: fix this sanakirja bound. + cfg_if::cfg_if! { + if #[cfg(all(feature = "sanakirja", not(feature = "heed")))] { + /// The primary key type. + type Primary: Pod + sanakirja::Storable; - /// The secondary key type. - /// - /// Only needs to be different than [`Key::Primary`] - /// if [`Key::DUPLICATE`] is `true`. - type Secondary; + /// The secondary key type. + /// + /// Only needs to be different than [`Key::Primary`] + /// if [`Key::DUPLICATE`] is `true`. + type Secondary: Pod + sanakirja::Storable; + } else { + /// The primary key type. + type Primary: Pod; + + /// The secondary key type. + /// + /// Only needs to be different than [`Key::Primary`] + /// if [`Key::DUPLICATE`] is `true`. + type Secondary: Pod; + } + } /// Acquire [`Key::Primary`]. fn primary(self) -> Self::Primary; @@ -105,23 +121,24 @@ impl_key! { // Implement `Key` for any [`DupKey`] using [`Copy`] types. impl
Key for DupKey
where
- P: Key + Copy,
- S: Key + Copy,
+ // TODO: fix sanakirja serde bound.
+ P: Pod + Copy,
+ S: Pod + Copy,
{
const DUPLICATE: bool = true;
- type Primary = Self;
+ type Primary = P;
type Secondary = S;
#[inline]
fn primary(self) -> Self::Primary {
- self
+ self.primary
}
#[inline]
fn primary_secondary(self) -> (Self::Primary, Self::Secondary) {
- (self, self.secondary)
+ (self.primary, self.secondary)
}
}
diff --git a/database/src/pod.rs b/database/src/pod.rs
index 5dc9c7b6..b7c1ed7d 100644
--- a/database/src/pod.rs
+++ b/database/src/pod.rs
@@ -111,6 +111,7 @@ mod private {
impl