zfs 0.1.0

Implementation of the ZFS file system.
Documentation
1
2
3
4
5
6
7
8
9
10
11
12
13
14
use std::{mem, ptr};

pub trait FromBytes: Sized {
    fn from_bytes(data: &[u8]) -> Result<Self, &str> {
        if data.len() >= mem::size_of::<Self>() {
            let s = unsafe { ptr::read(data.as_ptr() as *const Self) };
            Ok(s)
        } else {
            Err("Buffer not long enough.")
        }
    }
}

impl FromBytes for u64 {}