pub trait DeJson: Sized {
// Required method
fn de_json(
state: &mut DeJsonState,
input: &mut Chars<'_>
) -> Result<Self, DeJsonErr>;
// Provided method
fn deserialize_json(input: &str) -> Result<Self, DeJsonErr> { ... }
}
Expand description
A trait for objects that can be deserialized from JSON.
Required Methods§
sourcefn de_json(
state: &mut DeJsonState,
input: &mut Chars<'_>
) -> Result<Self, DeJsonErr>
fn de_json( state: &mut DeJsonState, input: &mut Chars<'_> ) -> Result<Self, DeJsonErr>
Parse Self from the input string.
let mut state = DeJsonState::default();
let mut chars = "42".chars();
state.next(&mut chars);
state.next_tok(&mut chars).unwrap();
let out = u32::de_json(&mut state, &mut chars).unwrap();
assert_eq!(out, 42);
Provided Methods§
sourcefn deserialize_json(input: &str) -> Result<Self, DeJsonErr>
fn deserialize_json(input: &str) -> Result<Self, DeJsonErr>
Parse Self from the input string.
This is a convenient wrapper around de_json
.
Object Safety§
This trait is not object safe.