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
impl StructuralIndex
Sourcepub fn token_count(&self) -> u32
pub fn token_count(&self) -> u32
Total number of stage1 tokens covered by this index.
Sourcepub fn kind(&self, tok: TokenId) -> TokenKind
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.
Sourcepub fn byte_offset(&self, tok: TokenId) -> u32
pub fn byte_offset(&self, tok: TokenId) -> u32
Byte offset of a token’s first byte in the source buffer.
Sourcepub fn byte_span(&self, tok: TokenId) -> ByteSpan
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.
Sourcepub fn byte_span_in(&self, tok: TokenId, bytes: &[u8]) -> ByteSpan
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).
pub fn parent(&self, tok: TokenId) -> Option<TokenId>
pub fn close_of(&self, container: TokenId) -> Option<TokenId>
pub fn tape_index(&self, tok: TokenId) -> Option<u32>
Sourcepub fn container_at_byte(&self, pos: u32) -> Option<TokenId>
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.
pub fn slice<'a>(&self, bytes: &'a [u8], tok: TokenId) -> &'a [u8] ⓘ
Sourcepub fn has_keys(&self) -> bool
pub fn has_keys(&self) -> bool
Whether the Mison key-bitmap layer was built (controlled by
BuildOptions::keys).
pub fn keys_named<'a>(&'a self, name: &str, depth: Option<u16>) -> KeyHits<'a> ⓘ
pub fn has_key(&self, name: &str) -> bool
pub fn keys_seen(&self) -> impl Iterator<Item = &str> + '_
pub fn value_for_key(&self, key_tok: TokenId) -> Option<TokenId>
Sourcepub fn keys_named_in<'a>(&'a self, name: &str, root: TokenId) -> KeyHits<'a> ⓘ
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).
Sourcepub fn field_of(&self, parent: TokenId, name: &str) -> Option<TokenId>
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.
Sourcepub fn subtree_bitmap(&self, root: TokenId) -> Bitmap
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.