diff options
Diffstat (limited to 'src/byte_order.rs')
-rw-r--r-- | src/byte_order.rs | 8 |
1 files changed, 8 insertions, 0 deletions
diff --git a/src/byte_order.rs b/src/byte_order.rs index f1c40e3..2f65ca8 100644 --- a/src/byte_order.rs +++ b/src/byte_order.rs @@ -53,6 +53,10 @@ pub trait ByteOrder { Ok(Self::read_ushort(data)?.map(move |data| data as i16)) } + fn write_ubyte(v: u8) -> [u8; 1] { + [v] + } + fn read_ubyte(data: &[u8]) -> DeserializeResult<u8> { match data.split_first() { Some((byte, rest)) => Deserialized::ok(*byte, rest), @@ -60,6 +64,10 @@ pub trait ByteOrder { } } + fn write_byte(v: i8) -> [u8; 1] { + [v as u8] + } + fn read_byte(data: &[u8]) -> DeserializeResult<i8> { Ok(Self::read_ubyte(data)?.map(move |b| b as i8)) } |