trackaudio
A Rust client library for TrackAudio, a modern voice communication application for VATSIM air traffic controllers.
This crate provides a high-level, async API for controlling TrackAudio programmatically via its WebSocket interface, enabling custom integrations, automation tools, and alternative user interfaces.
Features
- ๐ Async/await API โ Built on Tokio for efficient async I/O
- ๐ Type-safe โ Strongly-typed commands and events with full deserialization
- ๐ Request-response pattern โ High-level API for commands that expect responses
- ๐ก Event streaming โ Subscribe to real-time events from TrackAudio
- ๐ Automatic reconnection โ Resilient WebSocket connections with exponential backoff
- ๐งต Thread-safe โ Client can be safely shared across threads
- ๐ Tracing support โ Optional integration with the
tracingcrate
Quick start
Add the dependency to your Cargo.toml:
[]
= "0.1"
Connect to the default instance locally and listen for events:
use ;
async
High-level API
For common operations, use the TrackAudioApi wrapper:
use Duration;
use TrackAudioClient;
async
- Use
TrackAudioClientif you want full control (raw events, raw commands). - Use
TrackAudioApiif you want convenience with timeout-guarded request/response helpers.
For more detailed examples and API docs, check out the documentation.
Examples
Adding and configuring stations
use ;
use ;
use Duration;
async
Working with frequencies
use Frequency;
// Create frequencies in different units
let freq_hz = from_hz;
let freq_khz = from_khz;
let freq_mhz = from_mhz;
assert_eq!;
assert_eq!;
// Convert between units
println!;
println!;
println!;
// Convenient conversions
let freq: Frequency = 132.600_f64.into; // from MHz
let freq: Frequency = 132_600_000_u64.into; // from Hz
Monitoring RX/TX activity
use ;
async
Request-Response pattern
use TrackAudioClient;
use ;
use Duration;
async
Custom Configuration
use ;
use Duration;
async
Reconnection Configuration
The client automatically reconnects on connection loss with exponential backoff:
use ;
use Duration;
async
Supported URL Formats
The client supports flexible URL formats for connecting to TrackAudio:
- Full WebSocket URL:
ws://127.0.0.1:49080/wsorws://192.168.1.69/ws - Host only:
127.0.0.1orlocalhost(uses default port 49080 and/wspath) - Host and port:
127.0.0.1:12345(uses/wspath)
Note: TrackAudio currently only supports IPv4 connections and the ws:// scheme (no TLS/wss:// support).
API Overview
Core Types
TrackAudioClientโ The core WebSocket client for connection managementTrackAudioApiโ High-level API wrapper with convenient methodsTrackAudioConfigโ Configuration for connection parametersCommandโ Commands to send to TrackAudioEventโ Events emitted by TrackAudioFrequencyโ Radio frequency with convenient unit conversions
Error Handling
All operations return a Result<T, TrackAudioError>:
use ;
match connect_default.await
Features
tracing(enabled by default) โ Integrate with thetracingcrate for structured loggingreconnect-jitter(enabled by default) โ Add jitter to reconnection backoff to prevent thundering herd
To disable default features:
[]
= { = "0.1", = false }
Minimum Supported Rust Version (MSRV)
This crate requires Rust 1.85 or later.
License
The trackaudio project and all its crates and packages are dual-licensed as
- Apache License, Version 2.0 (LICENSE-APACHE or https://opensource.org/license/apache-2-0)
- MIT license (LICENSE-MIT or http://opensource.org/licenses/MIT)
at your option.
This means you can choose to use trackaudio under either the Apache-2.0 license or the MIT license.
Contributions
Unless you explicitly state otherwise, any contribution intentionally submitted for inclusion in the work by you, as defined in the Apache-2.0 license, shall be dual licensed as above, without any additional terms or conditions.
Contributing
Contributions are welcome! Whether you've found a bug, have a feature request, or want to improve the documentation, your input is valued.
Reporting Issues
If you encounter a bug or have a feature request, please open an issue on GitHub. When reporting a bug, please include:
- A clear description of the problem
- Steps to reproduce the issue
- The version of this crate used
- Your TrackAudio version
- Your Rust version (
rustc --version) - Your operating system
- Any relevant error messages or logs
Submitting Pull Requests
- Fork the repository and create a feature branch
- Write tests for new functionality (if applicable)
- Ensure
cargo test,cargo fmt, andcargo clippypass - Update documentation for API changes
- Submit your PR with a clear description of the changes
Note that this project uses Conventional Commits in combination with release-plz for automatic semantic versioning and release automation.
Please ensure your commits follow this format when submitting a PR.
For significant changes, please open an issue first to discuss your proposal.
Resources
Acknowledgments
This is an unofficial client library. TrackAudio is developed and maintained by Pierre.