diff options
Diffstat (limited to 'src/primitive/bufferid.rs')
| -rw-r--r-- | src/primitive/bufferid.rs | 16 |
1 files changed, 16 insertions, 0 deletions
diff --git a/src/primitive/bufferid.rs b/src/primitive/bufferid.rs index e987d85..59e1ace 100644 --- a/src/primitive/bufferid.rs +++ b/src/primitive/bufferid.rs @@ -2,10 +2,13 @@ #[repr(transparent)] pub struct BufferId(pub i32); +use crate::message::NetworkList; use crate::{error::ProtocolError, serialize::*}; use crate::serialize::UserType; +use super::Variant; + impl Serialize for BufferId { fn serialize(&self) -> Result<Vec<u8>, ProtocolError> { let mut res = Vec::new(); @@ -42,6 +45,19 @@ impl UserType for BufferId { const NAME: &str = "BufferId"; } +// TODO this is not correct usage, it's technically not really network repr were converting from +// but just the conversion of VariantList -> Self directly +impl NetworkList for Vec<BufferId> { + fn to_network_list(&self) -> super::VariantList { + self.iter().map(|b| Variant::BufferId(*b)).collect() + } + + fn from_network_list(input: &mut super::VariantList) -> Self { + input.iter().map(|b| match_variant!(b, Variant::BufferId)).collect() + } +} + + #[cfg(test)] mod tests { use super::*; |
