airport-data
A comprehensive Rust library for retrieving airport information by IATA codes, ICAO codes, and various other criteria. Provides access to a dataset of 5,000+ airports worldwide with detailed information including coordinates, timezone, type, and external links.
All airport data is embedded directly into the compiled binary — no network requests or external files needed at runtime.
Website: airportdata.dev | GitHub: aashishvanand/airport-data-rust | Docs: docs.rs/airport-data
Installation
Add this to your Cargo.toml:
[]
= "0.1"
Quick Start
use AirportData;
let db = new;
// Look up by IATA code
let airport = db.get_airport_by_iata.unwrap;
assert_eq!;
// Look up by ICAO code
let airport = db.get_airport_by_icao.unwrap;
assert_eq!;
Features
Core Search
use AirportData;
let db = new;
// Single airport lookup
let airport = db.get_airport_by_iata.unwrap;
println!;
// Search by name (case-insensitive substring match)
let results = db.search_by_name;
println!;
// Autocomplete suggestions
let suggestions = db.get_autocomplete_suggestions;
Geographic Queries
use AirportData;
let db = new;
// Find airports within 50 km of a point
let nearby = db.find_nearby_airports;
// Calculate distance between two airports (in km)
let distance = db.calculate_distance.unwrap;
// Find the nearest airport to coordinates
let nearest = db.find_nearest_airport.unwrap;
Filtering
use ;
let db = new;
// By country, continent, type, or timezone
let sg_airports = db.get_airports_by_country_code;
let asia_airports = db.get_airports_by_continent;
let large = db.get_airports_by_type;
// Advanced filtering
let filter = AirportFilter ;
let results = db.find_airports;
Statistics
use AirportData;
let db = new;
let stats = db.get_airport_stats_by_country.unwrap;
println!;
println!;
let continent_stats = db.get_airport_stats_by_continent.unwrap;
Distance Matrix
use AirportData;
let db = new;
let codes = vec!;
let matrix = db.calculate_distance_matrix.unwrap;
Validation
use AirportData;
let db = new;
assert!;
assert!;
assert!;
Airport Data Fields
Each Airport struct contains:
| Field | Type | Description |
|---|---|---|
iata |
String |
3-letter IATA code |
icao |
String |
4-letter ICAO code |
airport |
String |
Airport name |
latitude |
f64 |
Latitude |
longitude |
f64 |
Longitude |
timezone |
String |
IANA timezone (e.g. "Asia/Singapore") |
utc |
Option<f64> |
UTC offset |
country_code |
String |
2-letter country code |
continent |
String |
2-letter continent code |
elevation_ft |
Option<i64> |
Elevation in feet |
airport_type |
String |
Type (large_airport, medium_airport, small_airport, heliport, seaplane_base) |
scheduled_service |
bool |
Has scheduled commercial service |
runway_length |
Option<i64> |
Longest runway in feet |
wikipedia |
String |
Wikipedia URL |
website |
String |
Official website URL |
flightradar24_url |
String |
FlightRadar24 URL |
radarbox_url |
String |
RadarBox URL |
flightaware_url |
String |
FlightAware URL |
How It Works
The airport dataset (airports.json) is gzip-compressed at build time and embedded into the binary via include_bytes!. On first access, the data is decompressed and deserialized into memory, then cached for the lifetime of the process. The AirportData struct is zero-cost to construct.
License
This project is licensed under the Creative Commons Attribution 4.0 International License (CC-BY-4.0).