mirror of
https://github.com/mikedilger/chorus.git
synced 2026-08-31 07:31:01 +00:00
parse_u16(), parse_u32(), parse_u64() helper macros
This commit is contained in:
parent
fd24a99c77
commit
95688a9d8c
@ -55,3 +55,21 @@ macro_rules! read_hex {
|
||||
}
|
||||
}};
|
||||
}
|
||||
|
||||
macro_rules! parse_u16 {
|
||||
($input:expr, $start:expr) => {
|
||||
u16::from_ne_bytes($input[$start .. $start+2].try_into().unwrap())
|
||||
}
|
||||
}
|
||||
|
||||
macro_rules! parse_u32 {
|
||||
($input:expr, $start:expr) => {
|
||||
u32::from_ne_bytes($input[$start .. $start+4].try_into().unwrap())
|
||||
}
|
||||
}
|
||||
|
||||
macro_rules! parse_u64 {
|
||||
($input:expr, $start:expr) => {
|
||||
u64::from_ne_bytes($input[$start .. $start+8].try_into().unwrap())
|
||||
}
|
||||
}
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user