use jt808::models::{Jt808, Jt808BodySerialize, Jt808BodyTrans, Ver808};
use jt_util::bytes::{IBuffRead, IBuffWrite};
#[derive(Debug, Default)]
pub struct Jt0x9102 {
pub channel: u8,
pub cmd: u8,
pub close_type: u8,
pub switch_type: u8,
}
impl Jt808BodySerialize for Jt0x9102 {
fn write(&mut self, _ver: &Ver808, buf: &mut dyn IBuffWrite) {
buf.put_u8(self.channel);
buf.put_u8(self.cmd);
buf.put_u8(self.close_type);
buf.put_u8(self.switch_type);
}
fn len(&self, _ver: &Ver808) -> usize {
4
}
}
impl Jt808BodyTrans for Jt0x9102 {
fn fill_new<T>(buf: &mut T, _jt808: &Jt808) -> Self
where
T: IBuffRead,
{
Self {
channel: buf.get_u8(),
cmd: buf.get_u8(),
close_type: buf.get_u8(),
switch_type: buf.get_u8(),
}
}
}