Skip to main content

qrz_xml/
lib.rs

1//! # QRZ.com XML API Client
2//!
3//! A safe, async Rust client library for the QRZ.com XML API.
4//!
5//! This library provides a complete interface to QRZ.com's XML subscription data service,
6//! including callsign lookups, DXCC entity information, and biography data retrieval.
7//!
8//! ## Features
9//!
10//! - **Safe & Type-safe**: All API responses are parsed into strongly-typed Rust structs
11//! - **Async**: Built on tokio and reqwest for async/await support
12//! - **Session Management**: Automatic session handling with intelligent re-authentication
13//! - **Error Handling**: Comprehensive error types for all failure modes
14//! - **Rate Limiting**: Respects QRZ.com's usage guidelines
15//! - **Versioned API**: Support for QRZ's versioned XML interface
16//!
17//! ## Quick Start
18//!
19//! ```rust,no_run
20//! use qrz_xml::{QrzXmlClient, ApiVersion};
21//!
22//! #[tokio::main]
23//! async fn main() -> Result<(), Box<dyn std::error::Error>> {
24//!     let client = QrzXmlClient::new("your_username", "your_password", ApiVersion::Current)?;
25//!     
26//!     // Look up a callsign
27//!     let callsign_info = client.lookup_callsign("AA7BQ").await?;
28//!     println!("Found: {} - {}", callsign_info.call, callsign_info.fname.unwrap_or_default());
29//!     
30//!     // Look up DXCC entity
31//!     let dxcc_info = client.lookup_dxcc_entity(291).await?;
32//!     println!("DXCC 291: {}", dxcc_info.name);
33//!     
34//!     Ok(())
35//! }
36//! ```
37//!
38//! ## Authentication
39//!
40//! You need a valid QRZ.com username and password. While any QRZ user can authenticate,
41//! most features require an active QRZ Logbook Data subscription.
42
43pub mod client;
44pub mod error;
45pub mod types;
46
47pub use client::QrzXmlClient;
48pub use error::{QrzXmlError, Result};
49pub use types::{ApiVersion, BiographyData, CallsignInfo, DxccInfo, SessionInfo};
50
51/// Re-export commonly used types from chrono for convenience
52pub use chrono::{DateTime, Utc};
53
54/// The default base URL for QRZ's XML API
55pub const DEFAULT_BASE_URL: &str = "https://xmldata.qrz.com/xml";
56
57/// Default user agent string for requests
58pub const DEFAULT_USER_AGENT: &str = concat!("qrz-xml-rs/", env!("CARGO_PKG_VERSION"));
59
60#[allow(clippy::const_is_empty)]
61#[cfg(test)]
62mod tests {
63    use super::*;
64
65    #[test]
66    fn test_constants() {
67        assert!(!DEFAULT_BASE_URL.is_empty());
68        assert!(DEFAULT_USER_AGENT.contains("qrz-xml-rs"));
69    }
70}