Struct jsonl_converter::processors::byte_processor::ByteProcessor
source · pub struct ByteProcessor {
pub bracket_stack: BracketStack,
/* private fields */
}
Expand description
This struct contains the functionality to process a stream of bytes to convert JSON to JSONL. It keeps track of the brackets that have been opened but not closed, as well as the JSONL string that is being built.
Fields
bracket_stack
- A stack of brackets that have been opened but not closed.jsonl_string
- The JSONL string that is being built.
Fields§
§bracket_stack: BracketStack
Implementations§
source§impl ByteProcessor
impl ByteProcessor
sourcepub fn push_bracket(&mut self, byte: &char)
pub fn push_bracket(&mut self, byte: &char)
sourcepub fn process_char(&mut self, byte: &char)
pub fn process_char(&mut self, byte: &char)
Processes a character. This function will either add the character to the
jsonl_string
or print the jsonl_string
if the character is a closing
bracket and the bracket_stack
is empty (except for the initial
opening bracket).
Arguments
byte
- A character.
Examples
use jsonl_converter::processors::byte_processor::ByteProcessor;
let mut processor = ByteProcessor::new();
processor.push_bracket(&'[');
processor.process_char(&'{');
processor.process_char(&'a');
processor.process_char(&':');
processor.process_char(&'1');
processor.process_char(&'}');