#read-write #struct #byte-array #file #fs-file #u16 #u32

wraited-struct

Read and write struct with byte array

2 unstable releases

Uses old Rust 2015

0.2.0 Sep 18, 2018
0.1.0 Feb 20, 2017

#2873 in Rust patterns

24 downloads per month

Custom license

4KB

wraited-struct

Read and write struct

Usage

extern crate wraited_struct;
use std::fs::File;

#[derive(Debug)]
struct Something {
    a: u8,
    b: u16,
    c: u32,
}

fn main() {
    let mut file = File::create("customer.bin").unwrap();
    wraited_struct::write::<Something, File>(&mut file, Something { a: 97, b: 98, c: 99 }).unwrap();

    let mut file = File::open("customer.bin").unwrap();
    let something = wraited_struct::read::<Something, File>(&mut file).unwrap();
    println!("Something is {:?}", something);
}

No runtime deps