ironrdp_cliprdr/pdu/
lock.rs1use ironrdp_core::{
2 cast_int, ensure_fixed_part_size, Decode, DecodeResult, Encode, EncodeResult, ReadCursor, WriteCursor,
3};
4use ironrdp_pdu::impl_pdu_pod;
5
6use crate::pdu::PartialHeader;
7
8#[derive(Debug, Clone, PartialEq, Eq)]
10pub struct LockDataId(pub u32);
11
12impl_pdu_pod!(LockDataId);
13
14impl LockDataId {
15 const NAME: &'static str = "CLIPRDR_(UN)LOCK_CLIPDATA";
16 const FIXED_PART_SIZE: usize = 4 ;
17}
18
19impl Encode for LockDataId {
20 fn encode(&self, dst: &mut WriteCursor<'_>) -> EncodeResult<()> {
21 let header = PartialHeader::new(cast_int!("dataLen", Self::FIXED_PART_SIZE)?);
22 header.encode(dst)?;
23
24 ensure_fixed_part_size!(in: dst);
25 dst.write_u32(self.0);
26
27 Ok(())
28 }
29
30 fn name(&self) -> &'static str {
31 Self::NAME
32 }
33
34 fn size(&self) -> usize {
35 PartialHeader::SIZE + Self::FIXED_PART_SIZE
36 }
37}
38
39impl<'de> Decode<'de> for LockDataId {
40 fn decode(src: &mut ReadCursor<'de>) -> DecodeResult<Self> {
41 let _header = PartialHeader::decode(src)?;
42
43 ensure_fixed_part_size!(in: src);
44 let id = src.read_u32();
45
46 Ok(Self(id))
47 }
48}