Skip to main content

rtlsdr_pure/
lib.rs

1//! Pure Rust RTL-SDR driver built on top of `nusb`.
2//!
3//! The public API is async because `nusb` maps to both native USB and
4//! WebUSB. On native targets, use any executor or a small blocking helper in
5//! your application; the library itself does not require a runtime.
6
7mod error;
8mod r82xx;
9mod rtl2832;
10
11pub use error::{Error, Result};
12pub use rtl2832::{
13    DEFAULT_SAMPLE_RATE, DeviceDescription, GainMode, IqSample, KNOWN_DEVICES, KnownDevice, RtlSdr,
14    TunerKind, bytes_to_iq_samples,
15};
16
17/// Open the first known RTL2832U-based dongle and initialize it for SDR use.
18pub async fn open_first() -> Result<RtlSdr> {
19    RtlSdr::open_first().await
20}
21
22/// Return currently visible RTL-SDR devices.
23///
24/// WebUSB cannot enumerate arbitrary unpaired devices, so this helper is only
25/// available on native targets. Use [`open_first`] in browser builds; WebUSB
26/// will prompt the user if no matching device has already been granted.
27#[cfg(not(target_family = "wasm"))]
28pub async fn list_devices() -> Result<Vec<DeviceDescription>> {
29    RtlSdr::list_devices().await
30}