use crate::db::data::{FieldDecodeError, ValueStorageView};
#[derive(Clone, Debug, Eq, PartialEq)]
pub(in crate::db) struct CompiledPath {
segments: Vec<String>,
}
impl CompiledPath {
#[must_use]
pub(in crate::db) const fn new(segments: Vec<String>) -> Self {
Self { segments }
}
#[must_use]
pub(in crate::db) const fn segments(&self) -> &[String] {
self.segments.as_slice()
}
}
pub(in crate::db::executor::projection) fn resolve_path_segments<'a>(
raw_bytes: &'a [u8],
segment_bytes: &[Box<[u8]>],
) -> Result<Option<&'a [u8]>, FieldDecodeError> {
let mut current = ValueStorageView::from_raw_validated(raw_bytes)?;
for segment in segment_bytes {
current = match current.map_text_key_bytes(segment)? {
Some(next) => next,
None => return Ok(None),
};
}
Ok(Some(current.as_bytes()))
}