Skip to main content

decode_from_buffered_read

Function decode_from_buffered_read 

Source
pub fn decode_from_buffered_read<D: Decode, R: Read>(
    src: R,
    config: impl Config,
) -> Result<D>
Available on crate feature std only.
Expand description

Decode a value from any std::io::Read using an internal 8 KiB buffer.

Significantly more efficient than decode_from_std_read for file/network sources because it batches syscalls via BufferedIoReader.

ยงExamples

use std::io::Cursor;

let bytes = oxicode::encode_to_vec(&99u32).expect("encode failed");
let cursor = Cursor::new(bytes);
let decoded: u32 = oxicode::decode_from_buffered_read(cursor, oxicode::config::standard())
    .expect("decode failed");
assert_eq!(decoded, 99u32);