pub use ecdsa_signature::ECDSASignature;
pub use msg_certificate_chain::MsgCertificateChain;
pub use msg_certificate_chain_dep::MsgCertificateChainDep;
pub use msg_ecdsa_certificate::MsgEcdsaCertificate;
pub use msg_ecdsa_signature::MsgEcdsaSignature;
pub use msg_ecdsa_signature_dep_a::MsgEcdsaSignatureDepA;
pub use msg_ecdsa_signature_dep_b::MsgEcdsaSignatureDepB;
pub use msg_ed25519_certificate_dep::MsgEd25519CertificateDep;
pub use msg_ed25519_signature_dep_a::MsgEd25519SignatureDepA;
pub use msg_ed25519_signature_dep_b::MsgEd25519SignatureDepB;
pub use utc_time::UtcTime;
pub mod ecdsa_signature {
#![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 ECDSASignature {
#[cfg_attr(feature = "serde", serde(rename = "len"))]
pub len: u8,
#[cfg_attr(feature = "serde", serde(with = "BigArray", rename = "data"))]
pub data: [u8; 72],
}
impl WireFormat for ECDSASignature {
const MIN_LEN: usize = <u8 as WireFormat>::MIN_LEN + <[u8; 72] as WireFormat>::MIN_LEN;
fn len(&self) -> usize {
WireFormat::len(&self.len) + WireFormat::len(&self.data)
}
fn write<B: BufMut>(&self, buf: &mut B) {
WireFormat::write(&self.len, buf);
WireFormat::write(&self.data, buf);
}
fn parse_unchecked<B: Buf>(buf: &mut B) -> Self {
ECDSASignature {
len: WireFormat::parse_unchecked(buf),
data: WireFormat::parse_unchecked(buf),
}
}
}
}
pub mod msg_certificate_chain {
#![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 MsgCertificateChain {
#[cfg_attr(feature = "serde", serde(skip_serializing, alias = "sender"))]
pub sender_id: Option<u16>,
#[cfg_attr(feature = "serde", serde(rename = "root_certificate"))]
pub root_certificate: [u8; 20],
#[cfg_attr(feature = "serde", serde(rename = "intermediate_certificate"))]
pub intermediate_certificate: [u8; 20],
#[cfg_attr(feature = "serde", serde(rename = "corrections_certificate"))]
pub corrections_certificate: [u8; 20],
#[cfg_attr(feature = "serde", serde(rename = "expiration"))]
pub expiration: UtcTime,
#[cfg_attr(feature = "serde", serde(rename = "signature"))]
pub signature: ECDSASignature,
}
impl ConcreteMessage for MsgCertificateChain {
const MESSAGE_TYPE: u16 = 3081;
const MESSAGE_NAME: &'static str = "MSG_CERTIFICATE_CHAIN";
}
impl SbpMessage for MsgCertificateChain {
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 MsgCertificateChain {
fn friendly_name() -> &'static str {
"CERTIFICATE CHAIN"
}
}
impl TryFrom<Sbp> for MsgCertificateChain {
type Error = TryFromSbpError;
fn try_from(msg: Sbp) -> Result<Self, Self::Error> {
match msg {
Sbp::MsgCertificateChain(m) => Ok(m),
_ => Err(TryFromSbpError(msg)),
}
}
}
impl WireFormat for MsgCertificateChain {
const MIN_LEN: usize = <[u8; 20] as WireFormat>::MIN_LEN
+ <[u8; 20] as WireFormat>::MIN_LEN
+ <[u8; 20] as WireFormat>::MIN_LEN
+ <UtcTime as WireFormat>::MIN_LEN
+ <ECDSASignature as WireFormat>::MIN_LEN;
fn len(&self) -> usize {
WireFormat::len(&self.root_certificate)
+ WireFormat::len(&self.intermediate_certificate)
+ WireFormat::len(&self.corrections_certificate)
+ WireFormat::len(&self.expiration)
+ WireFormat::len(&self.signature)
}
fn write<B: BufMut>(&self, buf: &mut B) {
WireFormat::write(&self.root_certificate, buf);
WireFormat::write(&self.intermediate_certificate, buf);
WireFormat::write(&self.corrections_certificate, buf);
WireFormat::write(&self.expiration, buf);
WireFormat::write(&self.signature, buf);
}
fn parse_unchecked<B: Buf>(buf: &mut B) -> Self {
MsgCertificateChain {
sender_id: None,
root_certificate: WireFormat::parse_unchecked(buf),
intermediate_certificate: WireFormat::parse_unchecked(buf),
corrections_certificate: WireFormat::parse_unchecked(buf),
expiration: WireFormat::parse_unchecked(buf),
signature: WireFormat::parse_unchecked(buf),
}
}
}
}
pub mod msg_certificate_chain_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 MsgCertificateChainDep {
#[cfg_attr(feature = "serde", serde(skip_serializing, alias = "sender"))]
pub sender_id: Option<u16>,
#[cfg_attr(feature = "serde", serde(rename = "root_certificate"))]
pub root_certificate: [u8; 20],
#[cfg_attr(feature = "serde", serde(rename = "intermediate_certificate"))]
pub intermediate_certificate: [u8; 20],
#[cfg_attr(feature = "serde", serde(rename = "corrections_certificate"))]
pub corrections_certificate: [u8; 20],
#[cfg_attr(feature = "serde", serde(rename = "expiration"))]
pub expiration: UtcTime,
#[cfg_attr(feature = "serde", serde(with = "BigArray", rename = "signature"))]
pub signature: [u8; 64],
}
impl ConcreteMessage for MsgCertificateChainDep {
const MESSAGE_TYPE: u16 = 3077;
const MESSAGE_NAME: &'static str = "MSG_CERTIFICATE_CHAIN_DEP";
}
impl SbpMessage for MsgCertificateChainDep {
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 MsgCertificateChainDep {
fn friendly_name() -> &'static str {
"CERTIFICATE CHAIN DEP"
}
}
impl TryFrom<Sbp> for MsgCertificateChainDep {
type Error = TryFromSbpError;
fn try_from(msg: Sbp) -> Result<Self, Self::Error> {
match msg {
Sbp::MsgCertificateChainDep(m) => Ok(m),
_ => Err(TryFromSbpError(msg)),
}
}
}
impl WireFormat for MsgCertificateChainDep {
const MIN_LEN: usize = <[u8; 20] as WireFormat>::MIN_LEN
+ <[u8; 20] as WireFormat>::MIN_LEN
+ <[u8; 20] as WireFormat>::MIN_LEN
+ <UtcTime as WireFormat>::MIN_LEN
+ <[u8; 64] as WireFormat>::MIN_LEN;
fn len(&self) -> usize {
WireFormat::len(&self.root_certificate)
+ WireFormat::len(&self.intermediate_certificate)
+ WireFormat::len(&self.corrections_certificate)
+ WireFormat::len(&self.expiration)
+ WireFormat::len(&self.signature)
}
fn write<B: BufMut>(&self, buf: &mut B) {
WireFormat::write(&self.root_certificate, buf);
WireFormat::write(&self.intermediate_certificate, buf);
WireFormat::write(&self.corrections_certificate, buf);
WireFormat::write(&self.expiration, buf);
WireFormat::write(&self.signature, buf);
}
fn parse_unchecked<B: Buf>(buf: &mut B) -> Self {
MsgCertificateChainDep {
sender_id: None,
root_certificate: WireFormat::parse_unchecked(buf),
intermediate_certificate: WireFormat::parse_unchecked(buf),
corrections_certificate: WireFormat::parse_unchecked(buf),
expiration: WireFormat::parse_unchecked(buf),
signature: WireFormat::parse_unchecked(buf),
}
}
}
}
pub mod msg_ecdsa_certificate {
#![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 MsgEcdsaCertificate {
#[cfg_attr(feature = "serde", serde(skip_serializing, alias = "sender"))]
pub sender_id: Option<u16>,
#[cfg_attr(feature = "serde", serde(rename = "n_msg"))]
pub n_msg: u8,
#[cfg_attr(feature = "serde", serde(rename = "certificate_id"))]
pub certificate_id: [u8; 4],
#[cfg_attr(feature = "serde", serde(rename = "flags"))]
pub flags: u8,
#[cfg_attr(feature = "serde", serde(rename = "certificate_bytes"))]
pub certificate_bytes: Vec<u8>,
}
impl MsgEcdsaCertificate {
pub fn certificate_type(&self) -> Result<CertificateType, u8> {
get_bit_range!(self.flags, u8, u8, 2, 0).try_into()
}
pub fn set_certificate_type(&mut self, certificate_type: CertificateType) {
set_bit_range!(&mut self.flags, certificate_type, u8, u8, 2, 0);
}
}
impl ConcreteMessage for MsgEcdsaCertificate {
const MESSAGE_TYPE: u16 = 3076;
const MESSAGE_NAME: &'static str = "MSG_ECDSA_CERTIFICATE";
}
impl SbpMessage for MsgEcdsaCertificate {
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 MsgEcdsaCertificate {
fn friendly_name() -> &'static str {
"ECDSA CERTIFICATE"
}
}
impl TryFrom<Sbp> for MsgEcdsaCertificate {
type Error = TryFromSbpError;
fn try_from(msg: Sbp) -> Result<Self, Self::Error> {
match msg {
Sbp::MsgEcdsaCertificate(m) => Ok(m),
_ => Err(TryFromSbpError(msg)),
}
}
}
impl WireFormat for MsgEcdsaCertificate {
const MIN_LEN: usize = <u8 as WireFormat>::MIN_LEN
+ <[u8; 4] as WireFormat>::MIN_LEN
+ <u8 as WireFormat>::MIN_LEN
+ <Vec<u8> as WireFormat>::MIN_LEN;
fn len(&self) -> usize {
WireFormat::len(&self.n_msg)
+ WireFormat::len(&self.certificate_id)
+ WireFormat::len(&self.flags)
+ WireFormat::len(&self.certificate_bytes)
}
fn write<B: BufMut>(&self, buf: &mut B) {
WireFormat::write(&self.n_msg, buf);
WireFormat::write(&self.certificate_id, buf);
WireFormat::write(&self.flags, buf);
WireFormat::write(&self.certificate_bytes, buf);
}
fn parse_unchecked<B: Buf>(buf: &mut B) -> Self {
MsgEcdsaCertificate {
sender_id: None,
n_msg: WireFormat::parse_unchecked(buf),
certificate_id: WireFormat::parse_unchecked(buf),
flags: WireFormat::parse_unchecked(buf),
certificate_bytes: WireFormat::parse_unchecked(buf),
}
}
}
#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)]
pub enum CertificateType {
CorrectionsCertificate = 0,
RootCertificate = 1,
IntermediateCertificate = 2,
}
impl std::fmt::Display for CertificateType {
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
match self {
CertificateType::CorrectionsCertificate => f.write_str("Corrections certificate"),
CertificateType::RootCertificate => f.write_str("Root certificate"),
CertificateType::IntermediateCertificate => f.write_str("Intermediate certificate"),
}
}
}
impl TryFrom<u8> for CertificateType {
type Error = u8;
fn try_from(i: u8) -> Result<Self, u8> {
match i {
0 => Ok(CertificateType::CorrectionsCertificate),
1 => Ok(CertificateType::RootCertificate),
2 => Ok(CertificateType::IntermediateCertificate),
i => Err(i),
}
}
}
}
pub mod msg_ecdsa_signature {
#![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 MsgEcdsaSignature {
#[cfg_attr(feature = "serde", serde(skip_serializing, alias = "sender"))]
pub sender_id: Option<u16>,
#[cfg_attr(feature = "serde", serde(rename = "flags"))]
pub flags: u8,
#[cfg_attr(feature = "serde", serde(rename = "stream_counter"))]
pub stream_counter: u8,
#[cfg_attr(feature = "serde", serde(rename = "on_demand_counter"))]
pub on_demand_counter: u8,
#[cfg_attr(feature = "serde", serde(rename = "certificate_id"))]
pub certificate_id: [u8; 4],
#[cfg_attr(feature = "serde", serde(rename = "signature"))]
pub signature: ECDSASignature,
#[cfg_attr(feature = "serde", serde(rename = "signed_messages"))]
pub signed_messages: Vec<u8>,
}
impl MsgEcdsaSignature {
pub fn crc_type(&self) -> Result<CrcType, u8> {
get_bit_range!(self.flags, u8, u8, 1, 0).try_into()
}
pub fn set_crc_type(&mut self, crc_type: CrcType) {
set_bit_range!(&mut self.flags, crc_type, u8, u8, 1, 0);
}
}
impl ConcreteMessage for MsgEcdsaSignature {
const MESSAGE_TYPE: u16 = 3080;
const MESSAGE_NAME: &'static str = "MSG_ECDSA_SIGNATURE";
}
impl SbpMessage for MsgEcdsaSignature {
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 MsgEcdsaSignature {
fn friendly_name() -> &'static str {
"ECDSA SIGNATURE"
}
}
impl TryFrom<Sbp> for MsgEcdsaSignature {
type Error = TryFromSbpError;
fn try_from(msg: Sbp) -> Result<Self, Self::Error> {
match msg {
Sbp::MsgEcdsaSignature(m) => Ok(m),
_ => Err(TryFromSbpError(msg)),
}
}
}
impl WireFormat for MsgEcdsaSignature {
const MIN_LEN: usize = <u8 as WireFormat>::MIN_LEN
+ <u8 as WireFormat>::MIN_LEN
+ <u8 as WireFormat>::MIN_LEN
+ <[u8; 4] as WireFormat>::MIN_LEN
+ <ECDSASignature as WireFormat>::MIN_LEN
+ <Vec<u8> as WireFormat>::MIN_LEN;
fn len(&self) -> usize {
WireFormat::len(&self.flags)
+ WireFormat::len(&self.stream_counter)
+ WireFormat::len(&self.on_demand_counter)
+ WireFormat::len(&self.certificate_id)
+ WireFormat::len(&self.signature)
+ WireFormat::len(&self.signed_messages)
}
fn write<B: BufMut>(&self, buf: &mut B) {
WireFormat::write(&self.flags, buf);
WireFormat::write(&self.stream_counter, buf);
WireFormat::write(&self.on_demand_counter, buf);
WireFormat::write(&self.certificate_id, buf);
WireFormat::write(&self.signature, buf);
WireFormat::write(&self.signed_messages, buf);
}
fn parse_unchecked<B: Buf>(buf: &mut B) -> Self {
MsgEcdsaSignature {
sender_id: None,
flags: WireFormat::parse_unchecked(buf),
stream_counter: WireFormat::parse_unchecked(buf),
on_demand_counter: WireFormat::parse_unchecked(buf),
certificate_id: WireFormat::parse_unchecked(buf),
signature: WireFormat::parse_unchecked(buf),
signed_messages: WireFormat::parse_unchecked(buf),
}
}
}
#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)]
pub enum CrcType {
_24BitCrcsFromRtcmFraming = 0,
_16BitCrcsFromSbpFraming = 1,
}
impl std::fmt::Display for CrcType {
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
match self {
CrcType::_24BitCrcsFromRtcmFraming => f.write_str("24-bit CRCs from RTCM framing"),
CrcType::_16BitCrcsFromSbpFraming => f.write_str("16-bit CRCs from SBP framing"),
}
}
}
impl TryFrom<u8> for CrcType {
type Error = u8;
fn try_from(i: u8) -> Result<Self, u8> {
match i {
0 => Ok(CrcType::_24BitCrcsFromRtcmFraming),
1 => Ok(CrcType::_16BitCrcsFromSbpFraming),
i => Err(i),
}
}
}
}
pub mod msg_ecdsa_signature_dep_a {
#![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 MsgEcdsaSignatureDepA {
#[cfg_attr(feature = "serde", serde(skip_serializing, alias = "sender"))]
pub sender_id: Option<u16>,
#[cfg_attr(feature = "serde", serde(rename = "flags"))]
pub flags: u8,
#[cfg_attr(feature = "serde", serde(rename = "stream_counter"))]
pub stream_counter: u8,
#[cfg_attr(feature = "serde", serde(rename = "on_demand_counter"))]
pub on_demand_counter: u8,
#[cfg_attr(feature = "serde", serde(rename = "certificate_id"))]
pub certificate_id: [u8; 4],
#[cfg_attr(feature = "serde", serde(with = "BigArray", rename = "signature"))]
pub signature: [u8; 64],
#[cfg_attr(feature = "serde", serde(rename = "signed_messages"))]
pub signed_messages: Vec<u8>,
}
impl MsgEcdsaSignatureDepA {
pub fn crc_type(&self) -> Result<CrcType, u8> {
get_bit_range!(self.flags, u8, u8, 1, 0).try_into()
}
pub fn set_crc_type(&mut self, crc_type: CrcType) {
set_bit_range!(&mut self.flags, crc_type, u8, u8, 1, 0);
}
}
impl ConcreteMessage for MsgEcdsaSignatureDepA {
const MESSAGE_TYPE: u16 = 3078;
const MESSAGE_NAME: &'static str = "MSG_ECDSA_SIGNATURE_DEP_A";
}
impl SbpMessage for MsgEcdsaSignatureDepA {
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 MsgEcdsaSignatureDepA {
fn friendly_name() -> &'static str {
"ECDSA SIGNATURE DEP A"
}
}
impl TryFrom<Sbp> for MsgEcdsaSignatureDepA {
type Error = TryFromSbpError;
fn try_from(msg: Sbp) -> Result<Self, Self::Error> {
match msg {
Sbp::MsgEcdsaSignatureDepA(m) => Ok(m),
_ => Err(TryFromSbpError(msg)),
}
}
}
impl WireFormat for MsgEcdsaSignatureDepA {
const MIN_LEN: usize = <u8 as WireFormat>::MIN_LEN
+ <u8 as WireFormat>::MIN_LEN
+ <u8 as WireFormat>::MIN_LEN
+ <[u8; 4] as WireFormat>::MIN_LEN
+ <[u8; 64] as WireFormat>::MIN_LEN
+ <Vec<u8> as WireFormat>::MIN_LEN;
fn len(&self) -> usize {
WireFormat::len(&self.flags)
+ WireFormat::len(&self.stream_counter)
+ WireFormat::len(&self.on_demand_counter)
+ WireFormat::len(&self.certificate_id)
+ WireFormat::len(&self.signature)
+ WireFormat::len(&self.signed_messages)
}
fn write<B: BufMut>(&self, buf: &mut B) {
WireFormat::write(&self.flags, buf);
WireFormat::write(&self.stream_counter, buf);
WireFormat::write(&self.on_demand_counter, buf);
WireFormat::write(&self.certificate_id, buf);
WireFormat::write(&self.signature, buf);
WireFormat::write(&self.signed_messages, buf);
}
fn parse_unchecked<B: Buf>(buf: &mut B) -> Self {
MsgEcdsaSignatureDepA {
sender_id: None,
flags: WireFormat::parse_unchecked(buf),
stream_counter: WireFormat::parse_unchecked(buf),
on_demand_counter: WireFormat::parse_unchecked(buf),
certificate_id: WireFormat::parse_unchecked(buf),
signature: WireFormat::parse_unchecked(buf),
signed_messages: WireFormat::parse_unchecked(buf),
}
}
}
#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)]
pub enum CrcType {
_24BitCrcsFromRtcmFraming = 0,
_16BitCrcsFromSbpFraming = 1,
}
impl std::fmt::Display for CrcType {
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
match self {
CrcType::_24BitCrcsFromRtcmFraming => f.write_str("24-bit CRCs from RTCM framing"),
CrcType::_16BitCrcsFromSbpFraming => f.write_str("16-bit CRCs from SBP framing"),
}
}
}
impl TryFrom<u8> for CrcType {
type Error = u8;
fn try_from(i: u8) -> Result<Self, u8> {
match i {
0 => Ok(CrcType::_24BitCrcsFromRtcmFraming),
1 => Ok(CrcType::_16BitCrcsFromSbpFraming),
i => Err(i),
}
}
}
}
pub mod msg_ecdsa_signature_dep_b {
#![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 MsgEcdsaSignatureDepB {
#[cfg_attr(feature = "serde", serde(skip_serializing, alias = "sender"))]
pub sender_id: Option<u16>,
#[cfg_attr(feature = "serde", serde(rename = "flags"))]
pub flags: u8,
#[cfg_attr(feature = "serde", serde(rename = "stream_counter"))]
pub stream_counter: u8,
#[cfg_attr(feature = "serde", serde(rename = "on_demand_counter"))]
pub on_demand_counter: u8,
#[cfg_attr(feature = "serde", serde(rename = "certificate_id"))]
pub certificate_id: [u8; 4],
#[cfg_attr(feature = "serde", serde(rename = "n_signature_bytes"))]
pub n_signature_bytes: u8,
#[cfg_attr(feature = "serde", serde(with = "BigArray", rename = "signature"))]
pub signature: [u8; 72],
#[cfg_attr(feature = "serde", serde(rename = "signed_messages"))]
pub signed_messages: Vec<u8>,
}
impl MsgEcdsaSignatureDepB {
pub fn crc_type(&self) -> Result<CrcType, u8> {
get_bit_range!(self.flags, u8, u8, 1, 0).try_into()
}
pub fn set_crc_type(&mut self, crc_type: CrcType) {
set_bit_range!(&mut self.flags, crc_type, u8, u8, 1, 0);
}
}
impl ConcreteMessage for MsgEcdsaSignatureDepB {
const MESSAGE_TYPE: u16 = 3079;
const MESSAGE_NAME: &'static str = "MSG_ECDSA_SIGNATURE_DEP_B";
}
impl SbpMessage for MsgEcdsaSignatureDepB {
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 MsgEcdsaSignatureDepB {
fn friendly_name() -> &'static str {
"ECDSA SIGNATURE DEP B"
}
}
impl TryFrom<Sbp> for MsgEcdsaSignatureDepB {
type Error = TryFromSbpError;
fn try_from(msg: Sbp) -> Result<Self, Self::Error> {
match msg {
Sbp::MsgEcdsaSignatureDepB(m) => Ok(m),
_ => Err(TryFromSbpError(msg)),
}
}
}
impl WireFormat for MsgEcdsaSignatureDepB {
const MIN_LEN: usize = <u8 as WireFormat>::MIN_LEN
+ <u8 as WireFormat>::MIN_LEN
+ <u8 as WireFormat>::MIN_LEN
+ <[u8; 4] as WireFormat>::MIN_LEN
+ <u8 as WireFormat>::MIN_LEN
+ <[u8; 72] as WireFormat>::MIN_LEN
+ <Vec<u8> as WireFormat>::MIN_LEN;
fn len(&self) -> usize {
WireFormat::len(&self.flags)
+ WireFormat::len(&self.stream_counter)
+ WireFormat::len(&self.on_demand_counter)
+ WireFormat::len(&self.certificate_id)
+ WireFormat::len(&self.n_signature_bytes)
+ WireFormat::len(&self.signature)
+ WireFormat::len(&self.signed_messages)
}
fn write<B: BufMut>(&self, buf: &mut B) {
WireFormat::write(&self.flags, buf);
WireFormat::write(&self.stream_counter, buf);
WireFormat::write(&self.on_demand_counter, buf);
WireFormat::write(&self.certificate_id, buf);
WireFormat::write(&self.n_signature_bytes, buf);
WireFormat::write(&self.signature, buf);
WireFormat::write(&self.signed_messages, buf);
}
fn parse_unchecked<B: Buf>(buf: &mut B) -> Self {
MsgEcdsaSignatureDepB {
sender_id: None,
flags: WireFormat::parse_unchecked(buf),
stream_counter: WireFormat::parse_unchecked(buf),
on_demand_counter: WireFormat::parse_unchecked(buf),
certificate_id: WireFormat::parse_unchecked(buf),
n_signature_bytes: WireFormat::parse_unchecked(buf),
signature: WireFormat::parse_unchecked(buf),
signed_messages: WireFormat::parse_unchecked(buf),
}
}
}
#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)]
pub enum CrcType {
_24BitCrcsFromRtcmFraming = 0,
_16BitCrcsFromSbpFraming = 1,
}
impl std::fmt::Display for CrcType {
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
match self {
CrcType::_24BitCrcsFromRtcmFraming => f.write_str("24-bit CRCs from RTCM framing"),
CrcType::_16BitCrcsFromSbpFraming => f.write_str("16-bit CRCs from SBP framing"),
}
}
}
impl TryFrom<u8> for CrcType {
type Error = u8;
fn try_from(i: u8) -> Result<Self, u8> {
match i {
0 => Ok(CrcType::_24BitCrcsFromRtcmFraming),
1 => Ok(CrcType::_16BitCrcsFromSbpFraming),
i => Err(i),
}
}
}
}
pub mod msg_ed25519_certificate_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 MsgEd25519CertificateDep {
#[cfg_attr(feature = "serde", serde(skip_serializing, alias = "sender"))]
pub sender_id: Option<u16>,
#[cfg_attr(feature = "serde", serde(rename = "n_msg"))]
pub n_msg: u8,
#[cfg_attr(feature = "serde", serde(rename = "fingerprint"))]
pub fingerprint: [u8; 20],
#[cfg_attr(feature = "serde", serde(rename = "certificate_bytes"))]
pub certificate_bytes: Vec<u8>,
}
impl ConcreteMessage for MsgEd25519CertificateDep {
const MESSAGE_TYPE: u16 = 3074;
const MESSAGE_NAME: &'static str = "MSG_ED25519_CERTIFICATE_DEP";
}
impl SbpMessage for MsgEd25519CertificateDep {
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 MsgEd25519CertificateDep {
fn friendly_name() -> &'static str {
"ED25519 CERTIFICATE DEP"
}
}
impl TryFrom<Sbp> for MsgEd25519CertificateDep {
type Error = TryFromSbpError;
fn try_from(msg: Sbp) -> Result<Self, Self::Error> {
match msg {
Sbp::MsgEd25519CertificateDep(m) => Ok(m),
_ => Err(TryFromSbpError(msg)),
}
}
}
impl WireFormat for MsgEd25519CertificateDep {
const MIN_LEN: usize = <u8 as WireFormat>::MIN_LEN
+ <[u8; 20] as WireFormat>::MIN_LEN
+ <Vec<u8> as WireFormat>::MIN_LEN;
fn len(&self) -> usize {
WireFormat::len(&self.n_msg)
+ WireFormat::len(&self.fingerprint)
+ WireFormat::len(&self.certificate_bytes)
}
fn write<B: BufMut>(&self, buf: &mut B) {
WireFormat::write(&self.n_msg, buf);
WireFormat::write(&self.fingerprint, buf);
WireFormat::write(&self.certificate_bytes, buf);
}
fn parse_unchecked<B: Buf>(buf: &mut B) -> Self {
MsgEd25519CertificateDep {
sender_id: None,
n_msg: WireFormat::parse_unchecked(buf),
fingerprint: WireFormat::parse_unchecked(buf),
certificate_bytes: WireFormat::parse_unchecked(buf),
}
}
}
}
pub mod msg_ed25519_signature_dep_a {
#![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 MsgEd25519SignatureDepA {
#[cfg_attr(feature = "serde", serde(skip_serializing, alias = "sender"))]
pub sender_id: Option<u16>,
#[cfg_attr(feature = "serde", serde(with = "BigArray", rename = "signature"))]
pub signature: [u8; 64],
#[cfg_attr(feature = "serde", serde(rename = "fingerprint"))]
pub fingerprint: [u8; 20],
#[cfg_attr(feature = "serde", serde(rename = "signed_messages"))]
pub signed_messages: Vec<u32>,
}
impl ConcreteMessage for MsgEd25519SignatureDepA {
const MESSAGE_TYPE: u16 = 3073;
const MESSAGE_NAME: &'static str = "MSG_ED25519_SIGNATURE_DEP_A";
}
impl SbpMessage for MsgEd25519SignatureDepA {
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 MsgEd25519SignatureDepA {
fn friendly_name() -> &'static str {
"ED25519 SIGNATURE DEP A"
}
}
impl TryFrom<Sbp> for MsgEd25519SignatureDepA {
type Error = TryFromSbpError;
fn try_from(msg: Sbp) -> Result<Self, Self::Error> {
match msg {
Sbp::MsgEd25519SignatureDepA(m) => Ok(m),
_ => Err(TryFromSbpError(msg)),
}
}
}
impl WireFormat for MsgEd25519SignatureDepA {
const MIN_LEN: usize = <[u8; 64] as WireFormat>::MIN_LEN
+ <[u8; 20] as WireFormat>::MIN_LEN
+ <Vec<u32> as WireFormat>::MIN_LEN;
fn len(&self) -> usize {
WireFormat::len(&self.signature)
+ WireFormat::len(&self.fingerprint)
+ WireFormat::len(&self.signed_messages)
}
fn write<B: BufMut>(&self, buf: &mut B) {
WireFormat::write(&self.signature, buf);
WireFormat::write(&self.fingerprint, buf);
WireFormat::write(&self.signed_messages, buf);
}
fn parse_unchecked<B: Buf>(buf: &mut B) -> Self {
MsgEd25519SignatureDepA {
sender_id: None,
signature: WireFormat::parse_unchecked(buf),
fingerprint: WireFormat::parse_unchecked(buf),
signed_messages: WireFormat::parse_unchecked(buf),
}
}
}
}
pub mod msg_ed25519_signature_dep_b {
#![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 MsgEd25519SignatureDepB {
#[cfg_attr(feature = "serde", serde(skip_serializing, alias = "sender"))]
pub sender_id: Option<u16>,
#[cfg_attr(feature = "serde", serde(rename = "stream_counter"))]
pub stream_counter: u8,
#[cfg_attr(feature = "serde", serde(rename = "on_demand_counter"))]
pub on_demand_counter: u8,
#[cfg_attr(feature = "serde", serde(with = "BigArray", rename = "signature"))]
pub signature: [u8; 64],
#[cfg_attr(feature = "serde", serde(rename = "fingerprint"))]
pub fingerprint: [u8; 20],
#[cfg_attr(feature = "serde", serde(rename = "signed_messages"))]
pub signed_messages: Vec<u32>,
}
impl ConcreteMessage for MsgEd25519SignatureDepB {
const MESSAGE_TYPE: u16 = 3075;
const MESSAGE_NAME: &'static str = "MSG_ED25519_SIGNATURE_DEP_B";
}
impl SbpMessage for MsgEd25519SignatureDepB {
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 MsgEd25519SignatureDepB {
fn friendly_name() -> &'static str {
"ED25519 SIGNATURE DEP B"
}
}
impl TryFrom<Sbp> for MsgEd25519SignatureDepB {
type Error = TryFromSbpError;
fn try_from(msg: Sbp) -> Result<Self, Self::Error> {
match msg {
Sbp::MsgEd25519SignatureDepB(m) => Ok(m),
_ => Err(TryFromSbpError(msg)),
}
}
}
impl WireFormat for MsgEd25519SignatureDepB {
const MIN_LEN: usize = <u8 as WireFormat>::MIN_LEN
+ <u8 as WireFormat>::MIN_LEN
+ <[u8; 64] as WireFormat>::MIN_LEN
+ <[u8; 20] as WireFormat>::MIN_LEN
+ <Vec<u32> as WireFormat>::MIN_LEN;
fn len(&self) -> usize {
WireFormat::len(&self.stream_counter)
+ WireFormat::len(&self.on_demand_counter)
+ WireFormat::len(&self.signature)
+ WireFormat::len(&self.fingerprint)
+ WireFormat::len(&self.signed_messages)
}
fn write<B: BufMut>(&self, buf: &mut B) {
WireFormat::write(&self.stream_counter, buf);
WireFormat::write(&self.on_demand_counter, buf);
WireFormat::write(&self.signature, buf);
WireFormat::write(&self.fingerprint, buf);
WireFormat::write(&self.signed_messages, buf);
}
fn parse_unchecked<B: Buf>(buf: &mut B) -> Self {
MsgEd25519SignatureDepB {
sender_id: None,
stream_counter: WireFormat::parse_unchecked(buf),
on_demand_counter: WireFormat::parse_unchecked(buf),
signature: WireFormat::parse_unchecked(buf),
fingerprint: WireFormat::parse_unchecked(buf),
signed_messages: WireFormat::parse_unchecked(buf),
}
}
}
}
pub mod utc_time {
#![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 UtcTime {
#[cfg_attr(feature = "serde", serde(rename = "year"))]
pub year: u16,
#[cfg_attr(feature = "serde", serde(rename = "month"))]
pub month: u8,
#[cfg_attr(feature = "serde", serde(rename = "day"))]
pub day: u8,
#[cfg_attr(feature = "serde", serde(rename = "hours"))]
pub hours: u8,
#[cfg_attr(feature = "serde", serde(rename = "minutes"))]
pub minutes: u8,
#[cfg_attr(feature = "serde", serde(rename = "seconds"))]
pub seconds: u8,
#[cfg_attr(feature = "serde", serde(rename = "ns"))]
pub ns: u32,
}
impl WireFormat for UtcTime {
const MIN_LEN: usize = <u16 as WireFormat>::MIN_LEN
+ <u8 as WireFormat>::MIN_LEN
+ <u8 as WireFormat>::MIN_LEN
+ <u8 as WireFormat>::MIN_LEN
+ <u8 as WireFormat>::MIN_LEN
+ <u8 as WireFormat>::MIN_LEN
+ <u32 as WireFormat>::MIN_LEN;
fn len(&self) -> usize {
WireFormat::len(&self.year)
+ WireFormat::len(&self.month)
+ WireFormat::len(&self.day)
+ WireFormat::len(&self.hours)
+ WireFormat::len(&self.minutes)
+ WireFormat::len(&self.seconds)
+ WireFormat::len(&self.ns)
}
fn write<B: BufMut>(&self, buf: &mut B) {
WireFormat::write(&self.year, buf);
WireFormat::write(&self.month, buf);
WireFormat::write(&self.day, buf);
WireFormat::write(&self.hours, buf);
WireFormat::write(&self.minutes, buf);
WireFormat::write(&self.seconds, buf);
WireFormat::write(&self.ns, buf);
}
fn parse_unchecked<B: Buf>(buf: &mut B) -> Self {
UtcTime {
year: WireFormat::parse_unchecked(buf),
month: WireFormat::parse_unchecked(buf),
day: WireFormat::parse_unchecked(buf),
hours: WireFormat::parse_unchecked(buf),
minutes: WireFormat::parse_unchecked(buf),
seconds: WireFormat::parse_unchecked(buf),
ns: WireFormat::parse_unchecked(buf),
}
}
}
}