pub struct TapeRef<'a> { /* private fields */ }Expand description
A cursor over the simdjson DOM tape.
TapeRef borrows both the tape and the string buffer slices from a
simdjson_sys::dom_ffi::TapeView. It maintains a pos cursor that
advances as values are decoded.
The lifetime 'a is tied to the crate::dom::Parser that owns the
underlying memory, ensuring the tape remains valid.
Implementations§
Source§impl<'a> TapeRef<'a>
impl<'a> TapeRef<'a>
Sourcepub fn new(tape: &'a [u64], string_buf: &'a [u8]) -> Self
pub fn new(tape: &'a [u64], string_buf: &'a [u8]) -> Self
Create a new tape cursor positioned at index 0 (the root r node).
Sourcepub fn current_word_public(&self) -> u64
pub fn current_word_public(&self) -> u64
Public accessor for the raw tape word (needed by serde module).
Sourcepub fn payload_public(&self) -> u64
pub fn payload_public(&self) -> u64
Public accessor for payload (needed by serde module).
Sourcepub fn scope_close_idx(&self) -> usize
pub fn scope_close_idx(&self) -> usize
Returns the tape index of the closing } or ] for the current
StartObject or StartArray node.
In simdjson’s tape format, the opening bracket ({ or [) stores a
packed payload: the lower 32 bits are the next-sibling index (the
tape position of the first element after the closing bracket), and
the upper 24 bits encode the element count. The closing bracket is
therefore at next_sibling - 1.
Sourcepub fn scope_count(&self) -> usize
pub fn scope_count(&self) -> usize
Returns the number of direct children in the current [ / { scope.
simdjson packs the element count into bits 32–55 of the opening
bracket’s tape word (mask 0xFFFFFF after a >> 32). This matches
simdjson::internal::tape_ref::scope_count.
Sourcepub fn seek_public(&mut self, pos: usize)
pub fn seek_public(&mut self, pos: usize)
Move the cursor to an absolute tape index.
Sourcepub fn get_string(&self) -> Result<&'a str>
pub fn get_string(&self) -> Result<&'a str>
Decode the string at the current position.
The string buffer layout is: 4-byte native-endian length prefix followed
by raw UTF-8 bytes. The tape word payload is a byte offset into
string_buf.
The returned &str has lifetime 'a (tied to the parser), so it can
be used for zero-copy deserialization.
Sourcepub fn get_int64(&self) -> Result<i64>
pub fn get_int64(&self) -> Result<i64>
Decode the i64 value at the current position.
The actual integer is stored in the next tape word (reinterpreted as
i64 bits).
Sourcepub fn get_uint64(&self) -> Result<u64>
pub fn get_uint64(&self) -> Result<u64>
Decode the u64 value at the current position.
Sourcepub fn get_double(&self) -> Result<f64>
pub fn get_double(&self) -> Result<f64>
Decode the f64 value at the current position.
Sourcepub fn parse_value(&mut self) -> Result<Value<'a>>
pub fn parse_value(&mut self) -> Result<Value<'a>>
Parse the value at the current tape position into a zero-copy Value.
After a successful call the cursor is advanced past the parsed value, ready to decode the next element.
Sourcepub fn visit<V: TapeVisitor<'a>>(
&mut self,
visitor: &mut V,
) -> Result<V::Output>
pub fn visit<V: TapeVisitor<'a>>( &mut self, visitor: &mut V, ) -> Result<V::Output>
Visit the tape using a TapeVisitor.
This is the low-level API for custom traversal. The visitor receives structured callbacks as the tape is walked.