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]

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