use bytes::Bytes;
use rusty_modbus_types::MbapHeader;
#[derive(Debug, Clone)]
pub struct Frame {
pub header: FrameHeader,
pub pdu: Bytes,
}
#[derive(Debug, Clone, Copy)]
pub enum FrameHeader {
Mbap(MbapHeader),
Rtu {
unit_id: u8,
},
}
impl Frame {
#[must_use]
pub fn unit_id(&self) -> u8 {
match &self.header {
FrameHeader::Mbap(h) => h.unit_id,
FrameHeader::Rtu { unit_id } => *unit_id,
}
}
}
#[derive(Debug, Clone, Copy)]
pub struct RtuFrameMeta {
pub unit_id: u8,
pub pdu_length: usize,
pub crc: u16,
}