use crate::key_composer::{INLINE_CAP, KeyComposer, KeyTag, SmallKey};
#[inline(always)]
pub fn raw(kc: &KeyComposer, key: &[u8]) -> SmallKey {
if kc.is_default() {
let total_len = 4 + key.len();
if total_len <= INLINE_CAP {
let mut buf = [0u8; INLINE_CAP];
buf[0] = 0;
buf[1] = 0;
buf[2] = 0;
buf[3] = 0;
buf[4..total_len].copy_from_slice(key);
return SmallKey::Inline {
buf,
len: total_len as u8,
};
}
}
kc.compose_meta_key_stack(KeyTag::RawString.as_slice(), key)
}
#[inline]
pub fn raw_bytes(kc: &KeyComposer, key: &[u8]) -> Vec<u8> {
let mut v = Vec::with_capacity(kc.scope_prefix_len() + 1 + key.len());
kc.compose_meta_key_into(KeyTag::RawString.as_slice(), key, &mut v);
v
}
#[inline]
pub fn prefix(kc: &KeyComposer) -> Vec<u8> {
kc.compose_meta_prefix(KeyTag::RawString.as_slice())
}