#read #primitive #io-read #traits #type #extension

read-primitives

read-primitives provides traits to read primitive types from any type that implements std::io::Read

2 releases

0.1.1 Feb 6, 2023
0.1.0 Feb 6, 2023

#2981 in Rust patterns

Download history 5/week @ 2024-09-19 2/week @ 2024-09-26 3/week @ 2024-10-03 1/week @ 2024-10-24 10/week @ 2024-10-31 14/week @ 2024-11-07 57/week @ 2024-11-14 89/week @ 2024-11-21 66/week @ 2024-11-28 42/week @ 2024-12-05

259 downloads per month

MIT/Apache

8KB
103 lines

read-primitives

read-primitives adds several extension traits, that make it easy to read primitive types from any type that implements std::io::Read

Examples


    fn main() {
        let bytes: [u8; 8] = [24, 45, 68, 84, 251, 33, 9, 64];
        let float = bytes.as_slice().read_le_f64().unwrap();
        printf!("{float}");
    }

3.141592653589793


lib.rs:

read-primitives provides traits to read primitive types from any type that implements std::io::Read

Examples

use read_primitives::ReadF64;
let bytes: [u8; 8] = [24, 45, 68, 84, 251, 33, 9, 64];
let float = bytes.as_slice().read_le_f64().unwrap();
assert_eq!(std::f64::consts::PI, float)

Dependencies