Struct arya::JsonVerifier [−][src]
pub struct JsonVerifier { /* fields omitted */ }
a fast json syntax validator for utf8 sequences.
remarks
this parser can continue even when an invalid character is attempted.
invocations to update(<character>)
only update the state and validity of this parser if and only if the input
sequence would result in a valid json object.
if character
would cause this json object to become invalid, update()
will return an error but keep its state.
the next invocation of update()
will operate as if the bad character had never been applied.
in that sense, you can continue to "test" a character for json validity multiple times until one is foudn.
examples.
let mut json = JsonVerifier::new(); for character in r#"{ "name": "annie", "value": 1 }"#.bytes() { println!( "{} - {:?} - {:?}", character as char, json.update(character), json.status()); } // { - Ok(()) - Continue // - Ok(()) - Continue // " - Ok(()) - Continue // n - Ok(()) - Continue // a - Ok(()) - Continue // m - Ok(()) - Continue // e - Ok(()) - Continue // " - Ok(()) - Continue // : - Ok(()) - Continue // - Ok(()) - Continue // " - Ok(()) - Continue // a - Ok(()) - Continue // n - Ok(()) - Continue // n - Ok(()) - Continue // i - Ok(()) - Continue // e - Ok(()) - Continue // " - Ok(()) - Continue // , - Ok(()) - Continue // - Ok(()) - Continue // " - Ok(()) - Continue // v - Ok(()) - Continue // a - Ok(()) - Continue // l - Ok(()) - Continue // u - Ok(()) - Continue // e - Ok(()) - Continue // " - Ok(()) - Continue // : - Ok(()) - Continue // - Ok(()) - Continue // 1 - Ok(()) - Continue // - Ok(()) - Continue // } - Ok(()) - Valid
Methods
impl JsonVerifier
[src]
impl JsonVerifier
pub fn new() -> JsonVerifier
[src]
pub fn new() -> JsonVerifier
pub fn with_maximum_depth(maximum_depth: usize) -> JsonVerifier
[src]
pub fn with_maximum_depth(maximum_depth: usize) -> JsonVerifier
pub fn len(&self) -> usize
[src]
pub fn len(&self) -> usize
pub fn status(&self) -> JsonStatus
[src]
pub fn status(&self) -> JsonStatus
pub fn reset(&mut self)
[src]
pub fn reset(&mut self)
pub fn update(&mut self, character: u8) -> Result<(), JsonError>
[src]
pub fn update(&mut self, character: u8) -> Result<(), JsonError>
applies character
to this json object.
remarks
if character
would cause this json object to become invalid, this method returns an error, but keeps its
state. the next invocation of update()
will operate as if the bad character had never been applied.
Auto Trait Implementations
impl Send for JsonVerifier
impl Send for JsonVerifier
impl Sync for JsonVerifier
impl Sync for JsonVerifier