use crate::persistent_artrie::block_storage::BlockStorage;
use crate::persistent_artrie::error::Result;
use crate::persistent_artrie_core::key_encoding::{CharKey, KeyEncoding};
use crate::persistent_artrie_core::overlay::flip::LockFreeOverlay;
use crate::value::DictionaryValue;
impl<V: DictionaryValue, S: BlockStorage> super::PersistentARTrieChar<V, S> {
pub(crate) fn overlay_len(&self) -> usize {
<Self as LockFreeOverlay<CharKey, V, S>>::overlay_len(self)
}
pub(crate) fn overlay_is_empty(&self) -> bool {
<Self as LockFreeOverlay<CharKey, V, S>>::overlay_is_empty(self)
}
pub(crate) fn overlay_iter_prefix(&self, prefix: &str) -> Result<Option<Vec<String>>> {
let prefix_units = CharKey::units_from_str(prefix);
Ok(
<Self as LockFreeOverlay<CharKey, V, S>>::overlay_collect_units(self, &prefix_units)
.map(|seqs| seqs.iter().map(|u| CharKey::units_to_term(u)).collect()),
)
}
pub(crate) fn overlay_iter_prefix_with_values(
&self,
prefix: &str,
) -> Result<Option<Vec<(String, V)>>> {
let prefix_units = CharKey::units_from_str(prefix);
Ok(
<Self as LockFreeOverlay<CharKey, V, S>>::overlay_collect_units_with_values(
self,
&prefix_units,
)
.map(|seqs| {
seqs.into_iter()
.map(|(u, v)| (CharKey::units_to_term(&u), v))
.collect()
}),
)
}
pub(crate) fn overlay_get_value(&self, term: &str) -> Option<Option<V>>
where
S: 'static,
{
let units = CharKey::units_from_str(term);
<Self as LockFreeOverlay<CharKey, V, S>>::overlay_route_get_value(self, &units)
}
}