Modernize valid_lmdb_key

This commit is contained in:
Louis Dureuil 2025-01-08 15:22:11 +01:00
parent b4005593f4
commit fd88c834c3
No known key found for this signature in database

View File

@ -10,10 +10,10 @@ use fst::{IntoStreamer, Streamer};
pub use grenad_helpers::*; pub use grenad_helpers::*;
pub use merge_functions::*; pub use merge_functions::*;
use crate::{MAX_LMDB_KEY_LENGTH, MAX_WORD_LENGTH}; use crate::MAX_LMDB_KEY_LENGTH;
pub fn valid_lmdb_key(key: impl AsRef<[u8]>) -> bool { pub fn valid_lmdb_key(key: impl AsRef<[u8]>) -> bool {
key.as_ref().len() <= MAX_WORD_LENGTH * 2 && !key.as_ref().is_empty() key.as_ref().len() <= MAX_LMDB_KEY_LENGTH - 3 && !key.as_ref().is_empty()
} }
pub fn valid_facet_value(facet_value: impl AsRef<[u8]>) -> bool { pub fn valid_facet_value(facet_value: impl AsRef<[u8]>) -> bool {