18 lines
501 B
Rust
18 lines
501 B
Rust
|
pub fn as_u32_be(array: &[u8]) -> u32 {
|
||
|
((array[0] as u32) << 24)
|
||
|
+ ((array[1] as u32) << 16)
|
||
|
+ ((array[2] as u32) << 8)
|
||
|
+ ((array[3] as u32) << 0)
|
||
|
}
|
||
|
|
||
|
pub fn as_u64_be(array: &[u8]) -> u64 {
|
||
|
((array[0] as u64) << 56)
|
||
|
+ ((array[1] as u64) << 48)
|
||
|
+ ((array[2] as u64) << 40)
|
||
|
+ ((array[3] as u64) << 32)
|
||
|
+ ((array[4] as u64) << 24)
|
||
|
+ ((array[5] as u64) << 16)
|
||
|
+ ((array[6] as u64) << 8)
|
||
|
+ ((array[7] as u64) << 0)
|
||
|
}
|