Skip to main content

TapeRef

Struct TapeRef 

Source
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>

Source

pub fn new(tape: &'a [u64], string_buf: &'a [u8]) -> Self

Create a new tape cursor positioned at index 0 (the root r node).

Source

pub fn pos(&self) -> usize

Returns the current position in the tape.

Source

pub fn current_word_public(&self) -> u64

Public accessor for the raw tape word (needed by serde module).

Source

pub fn tape_type(&self) -> Option<TapeType>

Returns the type of the current tape node.

Source

pub fn payload_public(&self) -> u64

Public accessor for payload (needed by serde module).

Source

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.

Source

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.

Source

pub fn skip(&mut self, n: usize)

Advance the cursor by n tape words.

Source

pub fn seek_public(&mut self, pos: usize)

Move the cursor to an absolute tape index.

Source

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.

Source

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).

Source

pub fn get_uint64(&self) -> Result<u64>

Decode the u64 value at the current position.

Source

pub fn get_double(&self) -> Result<f64>

Decode the f64 value at the current position.

Source

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.

Source

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.

Trait Implementations§

Source§

impl<'a> Clone for TapeRef<'a>

Source§

fn clone(&self) -> TapeRef<'a>

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl<'a> Copy for TapeRef<'a>

Source§

impl<'a> Debug for TapeRef<'a>

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more

Auto Trait Implementations§

§

impl<'a> Freeze for TapeRef<'a>

§

impl<'a> RefUnwindSafe for TapeRef<'a>

§

impl<'a> Send for TapeRef<'a>

§

impl<'a> Sync for TapeRef<'a>

§

impl<'a> Unpin for TapeRef<'a>

§

impl<'a> UnsafeUnpin for TapeRef<'a>

§

impl<'a> UnwindSafe for TapeRef<'a>

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> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. 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> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

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

Source§

type Error = !

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

fn try_from(value: U) -> Result<T, !>

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.