feat(mavlink): adopt the kaptan-native dialect
This commit is contained in:
1 parent
1c90870634
commit
5f91465e66
87 files changed
+7733
-6850
No files matched your search
@@ -2,30 +2,7 @@
|
||||
|
||||
use crate::{Level, LogText};
|
||||
|
||||
/// Flags belonging exclusively to a log record.
|
||||
#[derive(Clone, Copy, Debug, Eq, PartialEq)]
|
||||
#[repr(transparent)]
|
||||
pub struct LogFlags(u8);
|
||||
|
||||
impl LogFlags {
|
||||
/// No optional flags.
|
||||
pub const NONE: Self = Self(0);
|
||||
/// Message text exceeded its fixed capacity.
|
||||
pub const TRUNCATED: Self = Self(1 << 1);
|
||||
|
||||
/// Raw transport bitmask.
|
||||
pub const fn bits(self) -> u8 {
|
||||
self.0
|
||||
}
|
||||
|
||||
/// Adds a bit.
|
||||
pub const fn with(self, other: Self) -> Self {
|
||||
Self(self.0 | other.0)
|
||||
}
|
||||
}
|
||||
|
||||
/// Internal transport priority selected from a conventional log level.
|
||||
#[derive(Clone, Copy, Debug, Eq, PartialEq)]
|
||||
pub enum DeliveryClass {
|
||||
/// Error-level logs.
|
||||
Critical,
|
||||
@@ -37,21 +14,13 @@ pub enum DeliveryClass {
|
||||
#[derive(Clone, Copy, Debug, Eq, PartialEq)]
|
||||
pub struct LogRecord {
|
||||
level: Level,
|
||||
flags: LogFlags,
|
||||
message: LogText,
|
||||
}
|
||||
|
||||
impl LogRecord {
|
||||
/// Creates one bounded log record at the supplied level.
|
||||
pub fn new(level: Level, mut flags: LogFlags, message: LogText) -> Self {
|
||||
if message.is_truncated() {
|
||||
flags = flags.with(LogFlags::TRUNCATED);
|
||||
}
|
||||
Self {
|
||||
level,
|
||||
flags,
|
||||
message,
|
||||
}
|
||||
pub(crate) const fn new(level: Level, message: LogText) -> Self {
|
||||
Self { level, message }
|
||||
}
|
||||
|
||||
/// Conventional log level.
|
||||
@@ -59,11 +28,6 @@ impl LogRecord {
|
||||
self.level
|
||||
}
|
||||
|
||||
/// Log-specific flag bitmask.
|
||||
pub const fn flags(&self) -> LogFlags {
|
||||
self.flags
|
||||
}
|
||||
|
||||
/// Fixed human-readable message.
|
||||
pub const fn message(&self) -> &LogText {
|
||||
&self.message
|
||||
|
||||
Reference in new issue
Block a user