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
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
#![warn(missing_docs)]
#![cfg_attr(feature = "cargo-clippy", allow(clippy::style))]
#![no_std]
mod array;
mod bits;
mod slice;
pub use array::{FromBytes, IntoBytes};
pub use slice::{ReadBytes, AsBytes};
pub use bits::Bits;
#[inline(always)]
pub const fn read_u16(input: &[u8], cursor: usize) -> u16 {
u16::from_ne_bytes([input[cursor], input[cursor + 1]])
}
#[inline(always)]
pub const fn read_u32(input: &[u8], cursor: usize) -> u32 {
u32::from_ne_bytes([input[cursor], input[cursor + 1], input[cursor + 2], input[cursor + 3]])
}
#[inline(always)]
pub const fn read_u64(input: &[u8], cursor: usize) -> u64 {
u64::from_ne_bytes([
input[cursor], input[cursor + 1], input[cursor + 2], input[cursor + 3],
input[cursor + 4], input[cursor + 5], input[cursor + 6], input[cursor + 7],
])
}
#[inline(always)]
pub const fn read_u128(input: &[u8], cursor: usize) -> u128 {
u128::from_ne_bytes([
input[cursor], input[cursor + 1], input[cursor + 2], input[cursor + 3],
input[cursor + 4], input[cursor + 5], input[cursor + 6], input[cursor + 7],
input[cursor + 8], input[cursor + 9], input[cursor + 10], input[cursor + 11],
input[cursor + 12], input[cursor + 13], input[cursor + 14], input[cursor + 15],
])
}