diff options
| author | Max Audron <audron@cocaine.farm> | 2025-07-27 01:51:14 +0200 |
|---|---|---|
| committer | Max Audron <audron@cocaine.farm> | 2025-07-27 01:51:14 +0200 |
| commit | d45e0a687ed5aa78f3e80bc5c335312bd81b2d4c (patch) | |
| tree | c93c3cb6839b707202f678d25dab0752182948c4 /src/primitive/bufferid.rs | |
| parent | fix sessioninit message wrongly using NetworkMap to convert a field (diff) | |
temporarly fix nested network repr parsing for variant types
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::*; |
