mirror of
https://github.com/meilisearch/meilisearch.git
synced 2024-11-26 03:55:07 +08:00
0a40a98bb6
* Make milli use edition 2021 * Add lifetime annotations to milli. * Run cargo fmt
23 lines
548 B
Rust
23 lines
548 B
Rust
use std::borrow::Cow;
|
|
|
|
use heed::BoxedError;
|
|
use obkv::{KvReaderU16, KvWriterU16};
|
|
|
|
pub struct ObkvCodec;
|
|
|
|
impl<'a> heed::BytesDecode<'a> for ObkvCodec {
|
|
type DItem = KvReaderU16<'a>;
|
|
|
|
fn bytes_decode(bytes: &'a [u8]) -> Result<Self::DItem, BoxedError> {
|
|
Ok(KvReaderU16::new(bytes))
|
|
}
|
|
}
|
|
|
|
impl heed::BytesEncode<'_> for ObkvCodec {
|
|
type EItem = KvWriterU16<Vec<u8>>;
|
|
|
|
fn bytes_encode(item: &Self::EItem) -> Result<Cow<'_, [u8]>, BoxedError> {
|
|
item.clone().into_inner().map(Cow::Owned).map_err(Into::into)
|
|
}
|
|
}
|