use crate::payload::{Decode, Encode, SeStringChunkKind}; use std::io::{Read, Seek}; use crate::Payload; #[derive(Debug, PartialEq)] pub struct IconPayload(pub u32); impl From for IconPayload { fn from(icon: u32) -> Self { Self(icon) } } impl Decode for IconPayload { fn decode(reader: R, _chunk_len: usize) -> Result { let icon = Self::read_integer(reader)?; Ok(Self(icon)) } } impl Encode for IconPayload { fn encode(&self) -> Vec { use std::iter::once; let index = Self::make_integer(self.0); let chunk_len = index.len() + 1; once(Payload::START_BYTE) .chain(once(SeStringChunkKind::Icon.as_u8())) .chain(once(chunk_len as u8)) .chain(index.into_iter()) .chain(once(Payload::END_BYTE)) .collect() } }