1use crate::enums::AlertDescription;
2use crate::error::InvalidMessage;
3use crate::msgs::codec::{Codec, Reader};
4use crate::msgs::enums::AlertLevel;
5
6use alloc::vec::Vec;
7
8#[derive(Debug)]
9pub struct AlertMessagePayload {
10 pub level: AlertLevel,
11 pub description: AlertDescription,
12}
13
14impl Codec for AlertMessagePayload {
15 fn encode(&self, bytes: &mut Vec<u8>) {
16 self.level.encode(bytes);
17 self.description.encode(bytes);
18 }
19
20 fn read(r: &mut Reader) -> Result<Self, InvalidMessage> {
21 let level: AlertLevel = AlertLevel::read(r)?;
22 let description: AlertDescription = AlertDescription::read(r)?;
23 r.expect_empty("AlertMessagePayload")
24 .map(|_| Self { level, description })
25 }
26}
27