milli_core/heed_codec/
byte_slice_ref.rs1use std::borrow::Cow;
2
3use heed::{BoxedError, BytesDecode, BytesEncode};
4
5pub struct BytesRefCodec;
8
9impl<'a> BytesEncode<'a> for BytesRefCodec {
10 type EItem = &'a [u8];
11
12 fn bytes_encode(item: &'a Self::EItem) -> Result<Cow<'a, [u8]>, BoxedError> {
13 Ok(Cow::Borrowed(item))
14 }
15}
16
17impl<'a> BytesDecode<'a> for BytesRefCodec {
18 type DItem = &'a [u8];
19
20 fn bytes_decode(bytes: &'a [u8]) -> Result<Self::DItem, BoxedError> {
21 Ok(bytes)
22 }
23}