Struct bytecodec::json_codec::JsonDecoder
[−]
[src]
pub struct JsonDecoder<T>(_)
where
T: for<'de> Deserialize<'de>;
JSON decoder.
Note that this decodes items monolithically so very large items may impair real-time property of the system.
Examples
use bytecodec::{Decode, Eos}; use bytecodec::json_codec::JsonDecoder; use serde_json::Value; let mut decoder = JsonDecoder::<Value>::new(); decoder.decode(b"[1, 2", Eos::new(false)).unwrap(); decoder.decode(b", 3]", Eos::new(true)).unwrap(); let json = decoder.finish_decoding().unwrap(); assert_eq!(json.to_string(), "[1,2,3]");
Methods
impl<T> JsonDecoder<T> where
T: for<'de> Deserialize<'de>,
[src]
T: for<'de> Deserialize<'de>,
Trait Implementations
impl<T: Debug> Debug for JsonDecoder<T> where
T: for<'de> Deserialize<'de>,
[src]
T: for<'de> Deserialize<'de>,
fn fmt(&self, __arg_0: &mut Formatter) -> Result
[src]
Formats the value using the given formatter. Read more
impl<T> Decode for JsonDecoder<T> where
T: for<'de> Deserialize<'de>,
[src]
T: for<'de> Deserialize<'de>,
type Item = T
The type of items to be decoded.
fn decode(&mut self, buf: &[u8], eos: Eos) -> Result<usize>
[src]
Consumes the given buffer (a part of a byte sequence), and proceeds the decoding process. Read more
fn finish_decoding(&mut self) -> Result<Self::Item>
[src]
Finishes the current decoding process and returns the decoded item. Read more
fn requiring_bytes(&self) -> ByteCount
[src]
Returns the lower bound of the number of bytes needed to decode the next item. Read more
fn is_idle(&self) -> bool
[src]
Returns true
if there are no items to be decoded by the decoder at the next invocation of decode
method, otherwise false
. Read more
impl<T> Default for JsonDecoder<T> where
T: for<'de> Deserialize<'de>,
[src]
T: for<'de> Deserialize<'de>,
Auto Trait Implementations
impl<T> Send for JsonDecoder<T> where
T: Send,
T: Send,
impl<T> Sync for JsonDecoder<T> where
T: Sync,
T: Sync,