pub struct Read<'a> { /* private fields */ }
Expand description
JSON input source that reads from a string/bytes-like JSON input.
Support most common types: &str, &u8, &FastStr, &Bytes and &String
§Examples
use bytes::Bytes;
use faststr::FastStr;
use serde::de::Deserialize;
use sonic_rs::{Deserializer, Read};
let mut de = Deserializer::new(Read::from(r#"123"#));
let num: i32 = Deserialize::deserialize(&mut de).unwrap();
assert_eq!(num, 123);
let mut de = Deserializer::new(Read::from(r#"123"#.as_bytes()));
let num: i32 = Deserialize::deserialize(&mut de).unwrap();
assert_eq!(num, 123);
let f = FastStr::new("123");
let mut de = Deserializer::new(Read::from(&f));
let num: i32 = Deserialize::deserialize(&mut de).unwrap();
assert_eq!(num, 123);
Implementations§
Auto Trait Implementations§
impl<'a> Freeze for Read<'a>
impl<'a> RefUnwindSafe for Read<'a>
impl<'a> Send for Read<'a>
impl<'a> Sync for Read<'a>
impl<'a> Unpin for Read<'a>
impl<'a> UnwindSafe for Read<'a>
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more