Skip to content

Commit

Permalink
unsigned long (always 32 bit, big endian byte order)
Browse files Browse the repository at this point in the history
  • Loading branch information
ismaileke committed Aug 25, 2024
1 parent 74bdf79 commit 1506cd8
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -194,11 +194,11 @@ pub mod binary {
self.buffer.push(((value >> 16) & 0xFF) as u8);
}

pub fn get_int(&mut self) -> i32 {
pub fn get_int(&mut self) -> u32 {
let bytes = self.get(4);
match bytes {
Ok(byte) => {
i32::from_be_bytes([byte[0], byte[1], byte[2], byte[3]])
u32::from_be_bytes([byte[0], byte[1], byte[2], byte[3]])
}
Err(err) => {
println!("Error get_int(): {}", err);
Expand All @@ -212,11 +212,11 @@ pub mod binary {
self.buffer.extend_from_slice(&bytes);
}

pub fn get_l_int(&mut self) -> i32 {
pub fn get_l_int(&mut self) -> u32 {
let bytes = self.get(4);
match bytes {
Ok(byte) => {
i32::from_le_bytes([byte[0], byte[1], byte[2], byte[3]])
u32::from_le_bytes([byte[0], byte[1], byte[2], byte[3]])
}
Err(err) => {
println!("Error get_l_int(): {}", err);
Expand Down

0 comments on commit 1506cd8

Please sign in to comment.