Skip to main content

StructuralIndex

Struct StructuralIndex 

Source
pub struct StructuralIndex { /* private fields */ }
Expand description

Opaque structural index over a JSON document. Internal layout is subject to change; consume only via the public methods.

Implementations§

Source§

impl StructuralIndex

Source

pub fn token_count(&self) -> u32

Total number of stage1 tokens covered by this index.

Source

pub fn max_depth(&self) -> u16

Maximum nesting depth observed in the source document.

Source

pub fn tokens(&self) -> Tokens<'_>

All tokens in document order.

Source

pub fn kind(&self, tok: TokenId) -> TokenKind

Classify a token as Object/Array/Key/String/Scalar/etc. Reads the stage1 kind plus (when keys are built) the role to disambiguate Quote-as-Key from Quote-as-Value.

Source

pub fn depth(&self, tok: TokenId) -> u16

Nesting depth of a token (root = 0).

Source

pub fn byte_offset(&self, tok: TokenId) -> u32

Byte offset of a token’s first byte in the source buffer.

Source

pub fn byte_span(&self, tok: TokenId) -> ByteSpan

Byte span of this token in the source.

Container (Object / Array): [open_off, close_off+1). Container close: single byte. String / Scalar: requires byte_span_in(tok, bytes) for byte-accurate ranges; this method returns a coarse upper bound by peeking at the next token’s offset. Use byte_span_in whenever you have the source bytes available.

Source

pub fn byte_span_in(&self, tok: TokenId, bytes: &[u8]) -> ByteSpan

Byte-accurate span using source bytes to find the exact end of strings (closing " honouring escapes) and scalars (next delimiter).

Source

pub fn parent(&self, tok: TokenId) -> Option<TokenId>

Source

pub fn close_of(&self, container: TokenId) -> Option<TokenId>

Source

pub fn tape_index(&self, tok: TokenId) -> Option<u32>

Source

pub fn container_at_byte(&self, pos: u32) -> Option<TokenId>

Innermost container token enclosing the given byte position. Returns None if pos is outside any container.

Source

pub fn ancestors(&self, tok: TokenId) -> Ancestors<'_>

Walk parents innermost→root.

Source

pub fn slice<'a>(&self, bytes: &'a [u8], tok: TokenId) -> &'a [u8]

Source

pub fn has_keys(&self) -> bool

Whether the Mison key-bitmap layer was built (controlled by BuildOptions::keys).

Source

pub fn keys_named<'a>(&'a self, name: &str, depth: Option<u16>) -> KeyHits<'a>

Source

pub fn has_key(&self, name: &str) -> bool

Source

pub fn keys_seen(&self) -> impl Iterator<Item = &str> + '_

Source

pub fn value_for_key(&self, key_tok: TokenId) -> Option<TokenId>

Source

pub fn keys_named_in<'a>(&'a self, name: &str, root: TokenId) -> KeyHits<'a>

Subtree-restricted key search: matches only tokens whose token-index falls within [root.raw(), close_of(root)].

Iterates the precomputed key bitmap via a borrowed roaring cursor — no bitmap allocation, no range AND. The returned KeyHits walks the underlying bitmap with reset_at_or_after(lo) and stops once the cursor’s value exceeds close_of(root).

Source

pub fn field_of(&self, parent: TokenId, name: &str) -> Option<TokenId>

Direct field lookup on a single container token: returns the value token of the named key, if present.

Walks the global key bitmap for name via a borrowed roaring cursor seeked to parent.0 + 1 and stopping at close_of(parent). Matches the first key token whose parent[] entry equals parent. No bitmap allocation, no range AND, no KeyHits materialisation — pure cursor seek over the precomputed key bitmap.

Source

pub fn subtree_bitmap(&self, root: TokenId) -> Bitmap

Subtree range as a bitmap. Cheap; range AND is a Roaring SIMD primitive on the consumer side.

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.