pub use msg_fwd::MsgFwd;
pub use msg_log::MsgLog;
pub use msg_print_dep::MsgPrintDep;
pub mod msg_fwd {
#![allow(unused_imports)]
use super::*;
use crate::messages::lib::*;
#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))]
#[allow(clippy::derive_partial_eq_without_eq)]
#[derive(Debug, PartialEq, Clone)]
pub struct MsgFwd {
#[cfg_attr(feature = "serde", serde(skip_serializing, alias = "sender"))]
pub sender_id: Option<u16>,
#[cfg_attr(feature = "serde", serde(rename = "source"))]
pub source: u8,
#[cfg_attr(feature = "serde", serde(rename = "protocol"))]
pub protocol: u8,
#[cfg_attr(feature = "serde", serde(rename = "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) -> Option<u16> {
Some(<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
}
fn is_valid(&self) -> bool {
true
}
fn into_valid_msg(self) -> Result<Self, crate::messages::invalid::Invalid> {
Ok(self)
}
}
impl FriendlyName for MsgFwd {
fn friendly_name() -> &'static str {
"FWD"
}
}
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(msg)),
}
}
}
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),
}
}
}
}
pub mod msg_log {
#![allow(unused_imports)]
use super::*;
use crate::messages::lib::*;
#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))]
#[allow(clippy::derive_partial_eq_without_eq)]
#[derive(Debug, PartialEq, Clone)]
pub struct MsgLog {
#[cfg_attr(feature = "serde", serde(skip_serializing, alias = "sender"))]
pub sender_id: Option<u16>,
#[cfg_attr(feature = "serde", serde(rename = "level"))]
pub level: u8,
#[cfg_attr(feature = "serde", serde(rename = "text"))]
pub text: SbpString<Vec<u8>, Unterminated>,
}
impl MsgLog {
pub fn logging_level(&self) -> Result<LoggingLevel, u8> {
get_bit_range!(self.level, u8, u8, 2, 0).try_into()
}
pub fn set_logging_level(&mut self, logging_level: LoggingLevel) {
set_bit_range!(&mut self.level, logging_level, u8, u8, 2, 0);
}
}
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) -> Option<u16> {
Some(<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
}
fn is_valid(&self) -> bool {
true
}
fn into_valid_msg(self) -> Result<Self, crate::messages::invalid::Invalid> {
Ok(self)
}
}
impl FriendlyName for MsgLog {
fn friendly_name() -> &'static str {
"LOG"
}
}
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(msg)),
}
}
}
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),
}
}
}
#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)]
pub enum LoggingLevel {
Emerg = 0,
Alert = 1,
Crit = 2,
Error = 3,
Warn = 4,
Notice = 5,
Info = 6,
Debug = 7,
}
impl std::fmt::Display for LoggingLevel {
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
match self {
LoggingLevel::Emerg => f.write_str("EMERG"),
LoggingLevel::Alert => f.write_str("ALERT"),
LoggingLevel::Crit => f.write_str("CRIT"),
LoggingLevel::Error => f.write_str("ERROR"),
LoggingLevel::Warn => f.write_str("WARN"),
LoggingLevel::Notice => f.write_str("NOTICE"),
LoggingLevel::Info => f.write_str("INFO"),
LoggingLevel::Debug => f.write_str("DEBUG"),
}
}
}
impl TryFrom<u8> for LoggingLevel {
type Error = u8;
fn try_from(i: u8) -> Result<Self, u8> {
match i {
0 => Ok(LoggingLevel::Emerg),
1 => Ok(LoggingLevel::Alert),
2 => Ok(LoggingLevel::Crit),
3 => Ok(LoggingLevel::Error),
4 => Ok(LoggingLevel::Warn),
5 => Ok(LoggingLevel::Notice),
6 => Ok(LoggingLevel::Info),
7 => Ok(LoggingLevel::Debug),
i => Err(i),
}
}
}
}
pub mod msg_print_dep {
#![allow(unused_imports)]
use super::*;
use crate::messages::lib::*;
#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))]
#[allow(clippy::derive_partial_eq_without_eq)]
#[derive(Debug, PartialEq, Clone)]
pub struct MsgPrintDep {
#[cfg_attr(feature = "serde", serde(skip_serializing, alias = "sender"))]
pub sender_id: Option<u16>,
#[cfg_attr(feature = "serde", serde(rename = "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) -> Option<u16> {
Some(<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
}
fn is_valid(&self) -> bool {
true
}
fn into_valid_msg(self) -> Result<Self, crate::messages::invalid::Invalid> {
Ok(self)
}
}
impl FriendlyName for MsgPrintDep {
fn friendly_name() -> &'static str {
"PRINT DEP"
}
}
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(msg)),
}
}
}
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),
}
}
}
}