pub struct CanonicalBytesScanner<'a> { /* private fields */ }Expand description
A zero-allocation canonical-layout recognizer over raw bytes.
Unlike converting the complete input with std::str::from_utf8 first,
this scanner validates only captured string fields. Structural fragments
are matched as ASCII bytes. A successful recognizer still proves that the
complete accepted layout is valid UTF-8 JSON because every byte is either
an exact ASCII literal, an ASCII number/boolean, or part of a validated
string.
Implementations§
Source§impl<'a> CanonicalBytesScanner<'a>
impl<'a> CanonicalBytesScanner<'a>
Sourcepub const fn new(input: &'a [u8]) -> Self
pub const fn new(input: &'a [u8]) -> Self
Starts matching a byte slice without a full-input UTF-8 pre-pass.
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 validates only its payload.
Sourcepub fn plain_ascii_string(&mut self) -> Option<&'a [u8]>
pub fn plain_ascii_string(&mut self) -> Option<&'a [u8]>
Consumes an unescaped ASCII JSON string and returns its bytes.
This is the fastest byte-input path for protocol identifiers and other
fields whose canonical form is ASCII. Non-ASCII input returns None so
the caller can fall back to Self::plain_string or a general parser.
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 CanonicalBytesScanner<'a>
impl<'a> Clone for CanonicalBytesScanner<'a>
Source§fn clone(&self) -> CanonicalBytesScanner<'a>
fn clone(&self) -> CanonicalBytesScanner<'a>
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read more