use super::lib::*;
#[cfg_attr(feature = "serde", derive(serde::Serialize))]
#[derive(Debug, Clone)]
pub struct MsgFwd {
#[cfg_attr(feature = "serde", serde(skip_serializing))]
pub sender_id: Option<u16>,
#[cfg_attr(feature = "serde", serde(rename(serialize = "source")))]
pub source: u8,
#[cfg_attr(feature = "serde", serde(rename(serialize = "protocol")))]
pub protocol: u8,
#[cfg_attr(feature = "serde", serde(rename(serialize = "fwd_payload")))]
pub fwd_payload: Vec<u8>,
}
impl ConcreteMessage for MsgFwd {
const MESSAGE_TYPE: u16 = 1026;
const MESSAGE_NAME: &'static str = "MSG_FWD";
}
impl SbpMessage for MsgFwd {
fn message_name(&self) -> &'static str {
<Self as ConcreteMessage>::MESSAGE_NAME
}
fn message_type(&self) -> u16 {
<Self as ConcreteMessage>::MESSAGE_TYPE
}
fn sender_id(&self) -> Option<u16> {
self.sender_id
}
fn set_sender_id(&mut self, new_id: u16) {
self.sender_id = Some(new_id);
}
fn encoded_len(&self) -> usize {
WireFormat::len(self) + crate::HEADER_LEN + crate::CRC_LEN
}
}
impl TryFrom<Sbp> for MsgFwd {
type Error = TryFromSbpError;
fn try_from(msg: Sbp) -> Result<Self, Self::Error> {
match msg {
Sbp::MsgFwd(m) => Ok(m),
_ => Err(TryFromSbpError),
}
}
}
impl WireFormat for MsgFwd {
const MIN_LEN: usize = <u8 as WireFormat>::MIN_LEN
+ <u8 as WireFormat>::MIN_LEN
+ <Vec<u8> as WireFormat>::MIN_LEN;
fn len(&self) -> usize {
WireFormat::len(&self.source)
+ WireFormat::len(&self.protocol)
+ WireFormat::len(&self.fwd_payload)
}
fn write<B: BufMut>(&self, buf: &mut B) {
WireFormat::write(&self.source, buf);
WireFormat::write(&self.protocol, buf);
WireFormat::write(&self.fwd_payload, buf);
}
fn parse_unchecked<B: Buf>(buf: &mut B) -> Self {
MsgFwd {
sender_id: None,
source: WireFormat::parse_unchecked(buf),
protocol: WireFormat::parse_unchecked(buf),
fwd_payload: WireFormat::parse_unchecked(buf),
}
}
}
#[cfg_attr(feature = "serde", derive(serde::Serialize))]
#[derive(Debug, Clone)]
pub struct MsgLog {
#[cfg_attr(feature = "serde", serde(skip_serializing))]
pub sender_id: Option<u16>,
#[cfg_attr(feature = "serde", serde(rename(serialize = "level")))]
pub level: u8,
#[cfg_attr(feature = "serde", serde(rename(serialize = "text")))]
pub text: SbpString<Vec<u8>, Unterminated>,
}
impl ConcreteMessage for MsgLog {
const MESSAGE_TYPE: u16 = 1025;
const MESSAGE_NAME: &'static str = "MSG_LOG";
}
impl SbpMessage for MsgLog {
fn message_name(&self) -> &'static str {
<Self as ConcreteMessage>::MESSAGE_NAME
}
fn message_type(&self) -> u16 {
<Self as ConcreteMessage>::MESSAGE_TYPE
}
fn sender_id(&self) -> Option<u16> {
self.sender_id
}
fn set_sender_id(&mut self, new_id: u16) {
self.sender_id = Some(new_id);
}
fn encoded_len(&self) -> usize {
WireFormat::len(self) + crate::HEADER_LEN + crate::CRC_LEN
}
}
impl TryFrom<Sbp> for MsgLog {
type Error = TryFromSbpError;
fn try_from(msg: Sbp) -> Result<Self, Self::Error> {
match msg {
Sbp::MsgLog(m) => Ok(m),
_ => Err(TryFromSbpError),
}
}
}
impl WireFormat for MsgLog {
const MIN_LEN: usize =
<u8 as WireFormat>::MIN_LEN + <SbpString<Vec<u8>, Unterminated> as WireFormat>::MIN_LEN;
fn len(&self) -> usize {
WireFormat::len(&self.level) + WireFormat::len(&self.text)
}
fn write<B: BufMut>(&self, buf: &mut B) {
WireFormat::write(&self.level, buf);
WireFormat::write(&self.text, buf);
}
fn parse_unchecked<B: Buf>(buf: &mut B) -> Self {
MsgLog {
sender_id: None,
level: WireFormat::parse_unchecked(buf),
text: WireFormat::parse_unchecked(buf),
}
}
}
#[cfg_attr(feature = "serde", derive(serde::Serialize))]
#[derive(Debug, Clone)]
pub struct MsgPrintDep {
#[cfg_attr(feature = "serde", serde(skip_serializing))]
pub sender_id: Option<u16>,
#[cfg_attr(feature = "serde", serde(rename(serialize = "text")))]
pub text: SbpString<Vec<u8>, Unterminated>,
}
impl ConcreteMessage for MsgPrintDep {
const MESSAGE_TYPE: u16 = 16;
const MESSAGE_NAME: &'static str = "MSG_PRINT_DEP";
}
impl SbpMessage for MsgPrintDep {
fn message_name(&self) -> &'static str {
<Self as ConcreteMessage>::MESSAGE_NAME
}
fn message_type(&self) -> u16 {
<Self as ConcreteMessage>::MESSAGE_TYPE
}
fn sender_id(&self) -> Option<u16> {
self.sender_id
}
fn set_sender_id(&mut self, new_id: u16) {
self.sender_id = Some(new_id);
}
fn encoded_len(&self) -> usize {
WireFormat::len(self) + crate::HEADER_LEN + crate::CRC_LEN
}
}
impl TryFrom<Sbp> for MsgPrintDep {
type Error = TryFromSbpError;
fn try_from(msg: Sbp) -> Result<Self, Self::Error> {
match msg {
Sbp::MsgPrintDep(m) => Ok(m),
_ => Err(TryFromSbpError),
}
}
}
impl WireFormat for MsgPrintDep {
const MIN_LEN: usize = <SbpString<Vec<u8>, Unterminated> as WireFormat>::MIN_LEN;
fn len(&self) -> usize {
WireFormat::len(&self.text)
}
fn write<B: BufMut>(&self, buf: &mut B) {
WireFormat::write(&self.text, buf);
}
fn parse_unchecked<B: Buf>(buf: &mut B) -> Self {
MsgPrintDep {
sender_id: None,
text: WireFormat::parse_unchecked(buf),
}
}
}