now_proto_pdu/system/
mod.rs1mod shutdown;
2
3use ironrdp_core::{DecodeResult, Encode, EncodeResult, IntoOwned, ReadCursor, WriteCursor};
4pub use shutdown::{NowSystemShutdownMsg, OwnedNowSystemShutdownMsg};
5
6use crate::NowHeader;
7
8#[derive(Debug, Clone, PartialEq, Eq)]
10pub enum NowSystemMessage<'a> {
11 Shutdown(NowSystemShutdownMsg<'a>),
12}
13
14pub type OwnedNowSystemMessage = NowSystemMessage<'static>;
15
16impl IntoOwned for NowSystemMessage<'_> {
17 type Owned = OwnedNowSystemMessage;
18
19 fn into_owned(self) -> Self::Owned {
20 match self {
21 Self::Shutdown(msg) => OwnedNowSystemMessage::Shutdown(msg.into_owned()),
22 }
23 }
24}
25
26impl<'a> NowSystemMessage<'a> {
27 const NAME: &'static str = "NOW_SYSTEM_MSG";
28
29 pub fn decode_from_body(header: NowHeader, src: &mut ReadCursor<'a>) -> DecodeResult<Self> {
30 match NowSystemMessageKind(header.kind) {
31 NowSystemMessageKind::SHUTDOWN => Ok(Self::Shutdown(NowSystemShutdownMsg::decode_from_body(header, src)?)),
32 _ => Err(unsupported_message_err!(class: header.class.0, kind: header.kind)),
33 }
34 }
35}
36
37impl Encode for NowSystemMessage<'_> {
38 fn encode(&self, dst: &mut WriteCursor<'_>) -> EncodeResult<()> {
39 match self {
40 Self::Shutdown(msg) => msg.encode(dst),
41 }
42 }
43
44 fn name(&self) -> &'static str {
45 Self::NAME
46 }
47
48 fn size(&self) -> usize {
49 match self {
50 Self::Shutdown(msg) => msg.size(),
51 }
52 }
53}
54
55#[derive(Debug, Clone, Copy, PartialEq, Eq)]
57pub struct NowSystemMessageKind(pub u8);
58
59impl NowSystemMessageKind {
60 pub const SHUTDOWN: Self = Self(0x03);
69}