[−][src]Struct arya::JsonVerifier
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
impl Send for JsonVerifier
impl Sync for JsonVerifier
Blanket Implementations
impl<T, U> Into for T where
U: From<T>,
[src]
U: From<T>,
impl<T> From for T
[src]
impl<T, U> TryFrom for T where
U: Into<T>,
[src]
U: Into<T>,
type Error = Infallible
The type returned in the event of a conversion error.
fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>
[src]
impl<T> Borrow for T where
T: ?Sized,
[src]
T: ?Sized,
impl<T> Any for T where
T: 'static + ?Sized,
[src]
T: 'static + ?Sized,
impl<T> BorrowMut for T where
T: ?Sized,
[src]
T: ?Sized,
fn borrow_mut(&mut self) -> &mut T
[src]
impl<T, U> TryInto for T where
U: TryFrom<T>,
[src]
U: TryFrom<T>,