pub struct StagedScanner { /* private fields */ }Expand description
Stateful JSON fragment scanner with buffer reuse
The scanner processes complete JSON documents to identify and extract JSON objects and arrays using a high-performance two-stage pipeline. Reuses internal buffers across multiple scans to eliminate allocation overhead.
§Example
use json_extractor::StagedScanner;
let mut scanner = StagedScanner::new();
let data = br#"{"name": "Alice"} {"age": 30}"#;
let fragments = scanner.scan_fragments(data);
assert_eq!(fragments.len(), 2);
assert!(fragments[0].is_complete());Implementations§
Source§impl StagedScanner
impl StagedScanner
Sourcepub fn new() -> Self
pub fn new() -> Self
Create a new scanner with empty buffers
§Example
use json_extractor::StagedScanner;
let mut scanner = StagedScanner::new();Sourcepub fn scan_fragments(&mut self, data: &[u8]) -> &[Fragment]
pub fn scan_fragments(&mut self, data: &[u8]) -> &[Fragment]
Scan a complete JSON document and extract all fragments
This method reuses internal buffers across calls for maximum performance. Buffers are cleared but not deallocated, preserving capacity.
§Arguments
data- Complete JSON document bytes
§Returns
Slice of all fragments found in the document (valid until next call)
§Example
use json_extractor::StagedScanner;
let mut scanner = StagedScanner::new();
let data = br#"{"name": "Alice"} {"age": 30}"#;
let fragments = scanner.scan_fragments(data);
assert_eq!(fragments.len(), 2);
assert!(fragments[0].is_complete());
assert_eq!(fragments[0].start, 0);Trait Implementations§
Auto Trait Implementations§
impl Freeze for StagedScanner
impl RefUnwindSafe for StagedScanner
impl Send for StagedScanner
impl Sync for StagedScanner
impl Unpin for StagedScanner
impl UnsafeUnpin for StagedScanner
impl UnwindSafe for StagedScanner
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