diff options
Diffstat (limited to 'src/primitive/unsignedint.rs')
| -rw-r--r-- | src/primitive/unsignedint.rs | 24 |
1 files changed, 23 insertions, 1 deletions
diff --git a/src/primitive/unsignedint.rs b/src/primitive/unsignedint.rs index b5d76cd..f0a78f7 100644 --- a/src/primitive/unsignedint.rs +++ b/src/primitive/unsignedint.rs @@ -6,7 +6,9 @@ use std::result::Result; use std::vec::Vec; use crate::error::ProtocolError; -use crate::{deserialize::*, serialize::*}; +use crate::{deserialize::*, primitive, serialize::*}; + +use crate::serialize::SerializeVariant; impl Serialize for bool { fn serialize(&self) -> Result<Vec<u8>, ProtocolError> { @@ -29,6 +31,10 @@ impl Deserialize for bool { } } +impl SerializeVariant for bool { + const TYPE: u32 = primitive::BOOL; +} + impl Serialize for u64 { fn serialize(&self) -> Result<Vec<u8>, ProtocolError> { Ok(Vec::from(self.to_be_bytes())) @@ -42,6 +48,10 @@ impl Deserialize for u64 { } } +impl SerializeVariant for u64 { + const TYPE: u32 = primitive::ULONG; +} + impl Serialize for u32 { fn serialize(&self) -> Result<Vec<u8>, ProtocolError> { Ok(Vec::from(self.to_be_bytes())) @@ -55,6 +65,10 @@ impl Deserialize for u32 { } } +impl SerializeVariant for u32 { + const TYPE: u32 = primitive::UINT; +} + impl Serialize for u16 { fn serialize(&self) -> Result<Vec<u8>, ProtocolError> { Ok(Vec::from(self.to_be_bytes())) @@ -68,6 +82,10 @@ impl Deserialize for u16 { } } +impl SerializeVariant for u16 { + const TYPE: u32 = primitive::USHORT; +} + impl Serialize for u8 { fn serialize(&self) -> Result<Vec<u8>, ProtocolError> { Ok(Vec::from(self.to_be_bytes())) @@ -79,3 +97,7 @@ impl Deserialize for u8 { return Ok((1, b[0])); } } + +impl SerializeVariant for u8 { + const TYPE: u32 = primitive::UCHAR; +} |
