[][src]Struct arya::JsonVerifier

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]

pub fn new() -> JsonVerifier[src]

pub fn with_maximum_depth(maximum_depth: usize) -> JsonVerifier[src]

pub fn len(&self) -> usize[src]

pub fn status(&self) -> JsonStatus[src]

pub fn reset(&mut self)[src]

pub fn update(&mut self, character: u8) -> Result<(), JsonError>[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

Blanket Implementations

impl<T, U> Into for T where
    U: From<T>, 
[src]

impl<T> From for T[src]

impl<T, U> TryFrom for T where
    U: Into<T>, 
[src]

type Error = Infallible

The type returned in the event of a conversion error.

impl<T> Borrow for T where
    T: ?Sized
[src]

impl<T> Any for T where
    T: 'static + ?Sized
[src]

impl<T> BorrowMut for T where
    T: ?Sized
[src]

impl<T, U> TryInto for T where
    U: TryFrom<T>, 
[src]

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.