#![no_std]
#![forbid(unsafe_code)]
#![warn(missing_docs)]
#[cfg(feature = "alloc")]
extern crate alloc;
#[cfg(feature = "std")]
extern crate std;
pub mod imapb;
pub mod klv;
mod math;
pub mod st0102;
pub mod st0601;
pub mod st0903;
#[cfg(doctest)]
#[doc = include_str!("../README.md")]
struct ReadmeDoctests;
#[cfg(doctest)]
#[doc = include_str!("../docs/integration.md")]
struct IntegrationDoctests;
use core::fmt;
#[derive(Clone, Copy, Debug, PartialEq, Eq)]
#[non_exhaustive]
pub enum Error {
Truncated,
BadLength,
WrongKey,
MissingChecksum,
Checksum {
found: u16,
computed: u16,
},
BadValue {
tag: u32,
},
OutOfRange {
tag: u32,
},
}
impl fmt::Display for Error {
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
match self {
Error::Truncated => f.write_str("KLV data ends early"),
Error::BadLength => f.write_str("malformed BER length or tag"),
Error::WrongKey => f.write_str("unexpected universal key"),
Error::MissingChecksum => f.write_str("packet does not end with a checksum item"),
Error::Checksum { found, computed } => {
write!(
f,
"checksum mismatch: packet says {found:#06x}, computed {computed:#06x}"
)
}
Error::BadValue { tag } => write!(f, "tag {tag}: value has the wrong type or length"),
Error::OutOfRange { tag } => {
write!(f, "tag {tag}: value outside the range the tag can carry")
}
}
}
}
#[cfg(feature = "std")]
impl std::error::Error for Error {}
#[derive(Clone, Copy, Debug, PartialEq)]
pub struct GeoPoint {
pub lat: f64,
pub lon: f64,
pub height: Option<f64>,
}