pub struct Scanner { /* private fields */ }Expand description
JSON scanner state machine.
The scanner operates on a byte buffer and tracks position. For streaming,
the buffer can be refilled when Token::NeedMore is returned.
Implementations§
Source§impl Scanner
impl Scanner
Sourcepub fn at_position(pos: usize) -> Self
pub fn at_position(pos: usize) -> Self
Create a scanner starting at a specific position
Sourcepub fn finalize_at_eof(&mut self, buf: &[u8]) -> Result<SpannedToken, ScanError>
pub fn finalize_at_eof(&mut self, buf: &[u8]) -> Result<SpannedToken, ScanError>
Finalize any pending token at true EOF.
Call this when the scanner returned NeedMore but no more data is available.
Returns the completed token if one is pending (e.g., a number at EOF),
or an error if the token is incomplete (e.g., unterminated string).
Sourcepub fn next_token(&mut self, buf: &[u8]) -> Result<SpannedToken, ScanError>
pub fn next_token(&mut self, buf: &[u8]) -> Result<SpannedToken, ScanError>
Scan the next token from the buffer.
Returns Token::NeedMore if the buffer is exhausted mid-token,
allowing the caller to refill and retry.
Trait Implementations§
Auto Trait Implementations§
impl Freeze for Scanner
impl RefUnwindSafe for Scanner
impl Send for Scanner
impl Sync for Scanner
impl Unpin for Scanner
impl UnwindSafe for Scanner
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more