Crate lazy_bytes_cast [] [src]

This crate provides simple methods to cast from and into byte arrays.

Note

The crates will not take care of byte order for you. Cuz lazy.

Usage example

extern crate lazy_bytes_cast;

use lazy_bytes_cast::{
    ToBytesCast,
    FromBytesCast
};

fn main() {
    let int_to: u32 = u32::max_value();
    println!("result={:?}", int_to.to_bytes());

    let bytes: [u8; 4] = [255, 255, 255, 255];
    let result: u32 = bytes.cast_to().unwrap();
    println!("result={}",result);
}

Traits

FromBytesCast

Trait to provide casting function to byte slices

ToBytesCast

Trait to provide to_bytes method for a arbitrary data.

Functions

bytes_cast

Converts slice of bytes to an integer.

bytes_cast_lazy

Unsafe version of bytes_cast

to_bytes

Converts data to a byte array.