pub struct DirectDecoder<R> { /* private fields */ }Expand description
Experimental and incomplete direct decoder.
WARNING: Do not use this to decode CBOR data that you don’t control. It is currently subject to an attack vector that permits an attacker to cause your process to abort due to an out-of-memory error. See: https://github.com/rust-lang/rustc-serialize/issues/115 (The normal decoder in this crate is not subject to this problem.)
A “direct” decoder is one that does not use an intermediate abstact syntax representation. Namely, the bytes are decoded directly into types. This significantly impacts performance. For example, it doesn’t have to box and unbox every data item.
However, implementing a direct decoder is much harder in the existing
serialization infrastructure. Currently, structs and enums are not
implemented. (But Vecs, tuples, Options and maps should work.)
Implementations§
Source§impl CborDecoder<Cursor<Vec<u8>>>
impl CborDecoder<Cursor<Vec<u8>>>
Sourcepub fn from_bytes<'a, T>(bytes: T) -> CborDecoder<Cursor<Vec<u8>>>
pub fn from_bytes<'a, T>(bytes: T) -> CborDecoder<Cursor<Vec<u8>>>
Create a new CBOR decoder that reads from the buffer given.
The buffer is usually given as either a Vec<u8> or a &[u8].
Source§impl<R: Read> CborDecoder<BufReader<R>>
impl<R: Read> CborDecoder<BufReader<R>>
Sourcepub fn from_reader(rdr: R) -> CborDecoder<BufReader<R>>
pub fn from_reader(rdr: R) -> CborDecoder<BufReader<R>>
Create a new CBOR decoder that reads from the reader given.