Skip to main content

libairspy_rs/
lib.rs

1//! Pure-Rust port of [libairspy] — USB driver for the Airspy R2 / Mini
2//! software-defined radio receivers, with no C library dependency.
3//!
4//! This is a faithful port: USB wire behavior, sample-pipeline
5//! semantics, and DSP output match the original C library, behind an
6//! idiomatic Rust surface (RAII device handles, `Result`-based errors,
7//! typed enums, and `Iterator`/`Stream`-based sample delivery).
8//!
9//! The crate is under active construction; the conversion is tracked in
10//! [milestones on GitHub](https://github.com/jasonherald/libairspy-rs/milestones).
11//!
12//! [libairspy]: https://github.com/airspy/airspyone_host
13#![warn(missing_docs)]
14
15pub mod board;
16pub mod commands;
17mod control;
18pub mod conversion;
19pub mod device;
20pub mod error;
21mod filters;
22mod iqconverter_float;
23mod iqconverter_int16;
24mod peripherals;
25pub mod reader;
26pub mod stream;
27#[cfg(feature = "smol")]
28pub mod stream_smol;
29#[cfg(feature = "tokio")]
30pub mod stream_tokio;
31#[cfg(test)]
32pub(crate) mod test_vectors;
33mod transfer;
34mod transport;
35
36pub use board::PartIdSerial;
37pub use conversion::Samples;
38pub use device::{Device, list_devices};
39pub use error::{Error, Result};
40
41/// Library version, mirroring `airspy_lib_version` /
42/// `airspy_lib_version_t` — reporting this crate's own version rather
43/// than the C library's 1.0.12.
44#[derive(Debug, Clone, Copy, PartialEq, Eq)]
45pub struct LibVersion {
46    /// `major_version`
47    pub major: u32,
48    /// `minor_version`
49    pub minor: u32,
50    /// `revision`
51    pub revision: u32,
52}
53
54/// The version of this crate (`airspy_lib_version` semantics).
55#[must_use]
56pub fn lib_version() -> LibVersion {
57    let parse = |s: &str| s.parse().unwrap_or(0);
58    LibVersion {
59        major: parse(env!("CARGO_PKG_VERSION_MAJOR")),
60        minor: parse(env!("CARGO_PKG_VERSION_MINOR")),
61        revision: parse(env!("CARGO_PKG_VERSION_PATCH")),
62    }
63}
64
65#[cfg(test)]
66mod tests {
67    use super::*;
68
69    #[test]
70    fn lib_version_matches_crate_version() {
71        let v = lib_version();
72        assert_eq!(
73            format!("{}.{}.{}", v.major, v.minor, v.revision),
74            env!("CARGO_PKG_VERSION")
75        );
76    }
77}