Skip to main content

rfham_core/
lib.rs

1//! Core data types for RF-Ham libraries.
2//!
3//! `rfham-core` provides foundational types shared across all crates in the `rust-rfham`
4//! ecosystem: callsign parsing, frequency and power measurements, country codes, regulatory
5//! agencies, and string-typed identifiers.
6//!
7//! # Type overview
8//!
9//! | Module | Key types | Purpose |
10//! |--------|-----------|---------|
11//! | [`callsign`] | [`callsign::CallSign`] | ITU-format amateur radio callsigns |
12//! | [`frequency`] | [`Frequency`], [`frequency::Wavelength`], [`frequency::FrequencyRange`] | RF frequency values and ranges |
13//! | [`power`] | [`Power`] | Transmit / receive power levels |
14//! | [`country`] | [`CountryCode`] | ISO 3166-1 alpha-2 country codes |
15//! | [`agency`] | [`Agency`] | Regulatory and standards bodies |
16//! | [`id`] | [`Name`], [`id::DisplayName`], [`id::Tag`] | Validated string identifiers |
17//! | [`fmt`] | [`fmt::Formatter`] | Custom formatting trait |
18//! | [`conversions`] | [`conversions::LengthInFeet`] | Imperial length representation |
19//!
20//! # Quick start
21//!
22//! ```rust
23//! use rfham_core::{
24//!     callsign::CallSign,
25//!     Frequency,
26//!     Power,
27//! };
28//!
29//! let callsign: CallSign = "K7SKJ/M".parse().unwrap();
30//! assert_eq!(callsign.prefix(), "K");
31//! assert!(callsign.is_mobile());
32//!
33//! let freq = Frequency::megahertz(146.52);
34//! let power = Power::watts(5.0);
35//! println!("{callsign} on {freq} at {power}");
36//! ```
37//!
38//! # Features
39//!
40//! - **`std`** *(default)*: enables `std`-backed dependencies (I/O errors, `LazyLock`, etc.).
41//!   Disable for `no_std` + `alloc` environments.
42
43#[allow(unused_extern_crates)]
44extern crate alloc;
45
46// ------------------------------------------------------------------------------------------------
47// Modules
48// ------------------------------------------------------------------------------------------------
49
50pub mod error;
51
52pub mod agencies;
53pub use agencies::Agency;
54pub mod callsigns;
55pub mod countries;
56pub mod non_si;
57pub use countries::CountryCode;
58pub mod fmt;
59pub mod frequencies;
60pub use frequencies::Frequency;
61pub mod names;
62pub use names::Name;
63pub mod power;
64pub use power::Power;