pub trait Decoder: Read + Sized {
Show 22 methods
// Provided methods
fn decode(&mut self) -> IoResult<Option<Value>> { ... }
fn decode_null(&mut self) -> IoResult<Option<()>> { ... }
fn decode_bool(&mut self) -> IoResult<Option<bool>> { ... }
fn decode_u8(&mut self) -> IoResult<Option<u8>> { ... }
fn decode_i8(&mut self) -> IoResult<Option<i8>> { ... }
fn decode_u16(&mut self) -> IoResult<Option<u16>> { ... }
fn decode_i16(&mut self) -> IoResult<Option<i16>> { ... }
fn decode_u32(&mut self) -> IoResult<Option<u32>> { ... }
fn decode_i32(&mut self) -> IoResult<Option<i32>> { ... }
fn decode_u64(&mut self) -> IoResult<Option<u64>> { ... }
fn decode_i64(&mut self) -> IoResult<Option<i64>> { ... }
fn decode_float(&mut self) -> IoResult<Option<f32>> { ... }
fn decode_double(&mut self) -> IoResult<Option<f64>> { ... }
fn decode_text(&mut self) -> IoResult<Option<String>> { ... }
fn decode_date_time(&mut self) -> IoResult<Option<String>> { ... }
fn decode_date(&mut self) -> IoResult<Option<String>> { ... }
fn decode_time(&mut self) -> IoResult<Option<String>> { ... }
fn decode_decimal_str(&mut self) -> IoResult<Option<String>> { ... }
fn decode_blob(&mut self) -> IoResult<Option<Blob>> { ... }
fn decode_list(&mut self) -> IoResult<Option<List>> { ... }
fn decode_map(&mut self) -> IoResult<Option<Map>> { ... }
fn decode_object(&mut self) -> IoResult<Option<Object>> { ... }
}
Expand description
Decoder
Usage
Decoding any values
You can use decode()
and a match
to filter values. This function will hand you the values after finishing decoding
process.
Decoding desired values
You can use decode_*()
. However, please note that: if an un-expected value is detected, the whole decoding operation might be broken.
It’s because those functions just decode the header of a value, and stop if not matched. So at that point, data stream is already broken.
In contrast, with decode()
, when you expect an Object
but get a List
, you can still
continue decoding next values.