1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
//! This library provides a data view for reading and writing data in a byte array.
//!
//! This library requires [feature(generic_const_exprs)](https://blog.rust-lang.org/inside-rust/2021/09/06/Splitting-const-generics.html) to be enabled. whice is a nightly feature.
//! So you need nightly compiler to use this library.
//!
//! It also works with `[no_std]` environment.
//!
//! By default, this library uses little endian as the default endian.
//! But you can override the endian by using `BE` (for big endian) or `NE` (for native endian) in fetures flag.
//!
//! For example, if you want to use big endian,  
//!
//! ```toml
//! data-view = { version = "0.1", features = ["BE"] }
//! ```
//!
//! # Examples
//! ```
//! use data_view::DataView;
//! 
//! let mut buf: [u8; 16] = [0; 16];
//! 
//! buf.write::<u16>(0, 42);
//! buf.write::<u32>(2, 123);
//! 
//! assert_eq!(buf.read::<u16>(0), 42);
//! assert_eq!(buf.read::<u32>(2), 123);
//! ```

#![no_std]
#![allow(incomplete_features)]
#![feature(generic_const_exprs)]

mod dataview;
mod endian;
mod view;

pub use dataview::DataView;
pub use endian::Endian;
pub use view::View;