Skip to content

Commit 43b0f84

Browse files
Sh3Rm4ncathay4t
authored andcommitted
Add parser for i8
1 parent ed3fc1b commit 43b0f84

File tree

1 file changed

+10
-0
lines changed

1 file changed

+10
-0
lines changed

Diff for: src/parsers.rs

+10
Original file line numberDiff line numberDiff line change
@@ -88,6 +88,16 @@ pub fn parse_u8(payload: &[u8]) -> Result<u8, DecodeError> {
8888
Ok(payload[0])
8989
}
9090

91+
pub fn parse_i8(payload: &[u8]) -> Result<i8, DecodeError> {
92+
if payload.len() != 1 {
93+
return Err(DecodeError::InvalidNumber {
94+
expected: 1,
95+
received: payload.len(),
96+
});
97+
}
98+
Ok(payload[0] as i8)
99+
}
100+
91101
pub fn parse_u32(payload: &[u8]) -> Result<u32, DecodeError> {
92102
if payload.len() != size_of::<u32>() {
93103
return Err(DecodeError::InvalidNumber {

0 commit comments

Comments
 (0)