Skip to main content

Scanner

Struct Scanner 

Source
pub struct Scanner<'de> { /* private fields */ }

Implementations§

Source§

impl<'de> Scanner<'de>

Source

pub fn new(input: &'de [u8]) -> Self

Source

pub fn new_str(s: &'de str) -> Self

Source

pub fn peek_byte(&self) -> Result<u8, Error>

Source

pub fn advance(&mut self)

Source

pub fn pos(&self) -> usize

Byte offset into the input slice — used by internally-tagged enum parsers to checkpoint and re-scan.

Source

pub fn set_pos(&mut self, saved_pos: usize)

Source

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

Source

pub fn remaining_input(&self) -> &'de [u8]

Remaining unprocessed input — used by single-pass float parsers (fast_float2::parse_partial).

Source

pub fn expect_byte(&mut self, expected: u8) -> Result<(), Error>

Source

pub fn expect_bytes(&mut self, expected: &[u8]) -> Result<(), Error>

Source

pub fn skip_whitespace(&mut self)

Source

pub fn peek_byte_after_ws(&mut self) -> Result<u8, Error>

Source

pub fn expect_eof(&mut self) -> Result<(), Error>

After parsing a top-level value, skip trailing whitespace and verify that no non-whitespace bytes remain (ECMA-404 requires a single value).

Source

pub fn read_key(&mut self) -> Result<&'de [u8], Error>

Read a JSON object key as a zero-copy &'de [u8]. Returns Error::EscapedKey if the key contains backslashes.

Source

pub fn read_key_colon(&mut self) -> Result<&'de [u8], Error>

Read a JSON object key and the mandatory : separator in one call.

Source

pub fn read_str(&mut self) -> Result<JsonStr<'de>, Error>

Read a JSON string value.

Returns JsonStr::BorrowedNoEsc when no escape sequences are present (zero allocation, provably escape-free), or JsonStr::Owned after unescaping.

Source

pub fn read_number_bytes(&mut self) -> Result<&'de [u8], Error>

Scan a JSON number and return the raw byte slice (zero-copy).

Source

pub fn peek_null(&mut self) -> bool

Returns true if the next (non-whitespace) bytes are null — does NOT consume.

Source

pub fn read_null(&mut self) -> Result<(), Error>

Source

pub fn read_bool(&mut self) -> Result<bool, Error>

Source

pub fn skip_value(&mut self) -> Result<(), Error>

Skip over any JSON value — used for unknown fields.

Source

pub fn skip_array_tail(&mut self) -> Result<(), Error>

Skip remaining array elements and the closing ]. Call this after a partial SeqAccess visit to drain any unconsumed elements so the scanner is positioned after the ].

Source

pub fn skip_object_tail(&mut self) -> Result<(), Error>

Skip remaining fields of an already-opened object (cursor is just past {). Used by internally-tagged enum deserialization when the variant is unknown.

Auto Trait Implementations§

§

impl<'de> Freeze for Scanner<'de>

§

impl<'de> RefUnwindSafe for Scanner<'de>

§

impl<'de> Send for Scanner<'de>

§

impl<'de> Sync for Scanner<'de>

§

impl<'de> Unpin for Scanner<'de>

§

impl<'de> UnsafeUnpin for Scanner<'de>

§

impl<'de> UnwindSafe for Scanner<'de>

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.