use quick_cache::Equivalent;
use uuid::Uuid;
use super::key::Key;
use crate::catalog::{DatabaseId, NamespaceId};
#[derive(Hash, Eq, PartialEq)]
pub(crate) enum Lookup<'a> {
#[cfg(feature = "jwks")]
Jwk(&'a str),
Fds(NamespaceId, DatabaseId, &'a str, Uuid),
Evs(NamespaceId, DatabaseId, &'a str, Uuid),
Fts(NamespaceId, DatabaseId, &'a str, Uuid),
Ixs(NamespaceId, DatabaseId, &'a str, Uuid),
Lvs(NamespaceId, DatabaseId, &'a str, Uuid),
}
impl Equivalent<Key> for Lookup<'_> {
#[rustfmt::skip]
fn equivalent(&self, key: &Key) -> bool {
match (self, key) {
#[cfg(feature = "jwks")]
(Self::Jwk(la), Key::Jwk(ka)) => la == ka,
(Self::Fds(la, lb, lc, ld), Key::Fds(ka, kb, kc, kd)) => la == ka && lb == kb && lc == kc && ld == kd,
(Self::Evs(la, lb, lc, ld), Key::Evs(ka, kb, kc, kd)) => la == ka && lb == kb && lc == kc && ld == kd,
(Self::Fts(la, lb, lc, ld), Key::Fts(ka, kb, kc, kd)) => la == ka && lb == kb && lc == kc && ld == kd,
(Self::Ixs(la, lb, lc, ld), Key::Ixs(ka, kb, kc, kd)) => la == ka && lb == kb && lc == kc && ld == kd,
(Self::Lvs(la, lb, lc, ld), Key::Lvs(ka, kb, kc, kd)) => la == ka && lb == kb && lc == kc && ld == kd,
_ => false,
}
}
}