From d45e0a687ed5aa78f3e80bc5c335312bd81b2d4c Mon Sep 17 00:00:00 2001 From: Max Audron Date: Sun, 27 Jul 2025 01:51:14 +0200 Subject: temporarly fix nested network repr parsing for variant types --- src/primitive/bufferid.rs | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) (limited to 'src/primitive/bufferid.rs') 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, 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 { + 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::*; -- cgit v1.2.3