pub struct CanonicalScanner<'a> { /* private fields */ }Expand description
A zero-allocation recognizer for a known canonical JSON layout.
This is not a general JSON parser. It is an optimization primitive for
generated or protocol-specific code that first attempts one exact layout
and falls back to crate::JsonCursor when any expectation does not match.
Every successful recognizer must consume and check the complete input.
Implementations§
Source§impl<'a> CanonicalScanner<'a>
impl<'a> CanonicalScanner<'a>
Sourcepub fn literal(&mut self, expected: &str) -> Option<()>
pub fn literal(&mut self, expected: &str) -> Option<()>
Consumes an exact string fragment.
Returns None without advancing when the sequence does not match.
Sourcepub fn plain_string(&mut self) -> Option<&'a str>
pub fn plain_string(&mut self) -> Option<&'a str>
Consumes a JSON string with no escapes and returns its borrowed value.
Escaped strings deliberately return None so the caller can use the
general parser instead.
Sourcepub const fn is_finished(&self) -> bool
pub const fn is_finished(&self) -> bool
Returns true only when the recognizer consumed the complete input.
Trait Implementations§
Source§impl<'a> Clone for CanonicalScanner<'a>
impl<'a> Clone for CanonicalScanner<'a>
Source§fn clone(&self) -> CanonicalScanner<'a>
fn clone(&self) -> CanonicalScanner<'a>
Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source. Read moreimpl<'a> Copy for CanonicalScanner<'a>
Auto Trait Implementations§
impl<'a> Freeze for CanonicalScanner<'a>
impl<'a> RefUnwindSafe for CanonicalScanner<'a>
impl<'a> Send for CanonicalScanner<'a>
impl<'a> Sync for CanonicalScanner<'a>
impl<'a> Unpin for CanonicalScanner<'a>
impl<'a> UnsafeUnpin for CanonicalScanner<'a>
impl<'a> UnwindSafe for CanonicalScanner<'a>
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