ironrdp_pdu/rdp/capability_sets/
sound.rs1#[cfg(test)]
2mod tests;
3
4use bitflags::bitflags;
5use ironrdp_core::{
6 ensure_fixed_part_size, read_padding, write_padding, Decode, DecodeResult, Encode, EncodeResult, ReadCursor,
7 WriteCursor,
8};
9
10const SOUND_LENGTH: usize = 4;
11
12bitflags! {
13 #[derive(Debug, Clone, Copy, PartialEq, Eq, PartialOrd, Ord, Hash)]
14 pub struct SoundFlags: u16 {
15 const BEEPS = 1;
16 }
17}
18
19#[derive(Debug, PartialEq, Eq, Clone)]
20pub struct Sound {
21 pub flags: SoundFlags,
22}
23
24impl Sound {
25 const NAME: &'static str = "Sound";
26
27 const FIXED_PART_SIZE: usize = SOUND_LENGTH;
28}
29
30impl Encode for Sound {
31 fn encode(&self, dst: &mut WriteCursor<'_>) -> EncodeResult<()> {
32 ensure_fixed_part_size!(in: dst);
33
34 dst.write_u16(self.flags.bits());
35 write_padding!(dst, 2);
36
37 Ok(())
38 }
39
40 fn name(&self) -> &'static str {
41 Self::NAME
42 }
43
44 fn size(&self) -> usize {
45 Self::FIXED_PART_SIZE
46 }
47}
48
49impl<'de> Decode<'de> for Sound {
50 fn decode(src: &mut ReadCursor<'de>) -> DecodeResult<Self> {
51 ensure_fixed_part_size!(in: src);
52
53 let flags = SoundFlags::from_bits_truncate(src.read_u16());
54 read_padding!(src, 2);
55
56 Ok(Sound { flags })
57 }
58}