Crate uap

Source
Expand description

This crate provides a unified interface to several sources of information on aircraft worldwide, including registration and type information.

The main use case is finding an aircraft’s registration (“tail number”) if you have its ICAO code (AKA Mode S code). ICAO codes can be broadcast by aircraft transponders, so if you’re looking at a transponder data packet and want to find out more about the aircraft that sent it, the first step is often to find its registration.

This crate currently supports two source of information, both of which can be downloaded by the public:

  • The FAA registration database. The FAA database has information on all aircraft in the United States with civilian registrations.
  • The Mictronics database; Specifically, the “Complete database for old readsb (non protocol buffer version)” zip file that’s contained at this link. The Microntronics database tries to collect information on all aircraft in the world, including military aircraft.

To use this crate, you need to

  1. Download the FAA database zip, or the Mictronics database, or both.
  2. Unzip the database(s) into a directory.
  3. Call faa::Faa::from_dir() or mictronics::Mictronics::from_dir() with the directory containing the database files.
  4. Call the resulting struct’s lookup_mode_s function with the Mode S code of the aircraft you want information on.
use uap::Database;
use uap::faa::Faa;
use uap::mictronics::Mictronics;
use std::str::FromStr;

// ./tests/data/faa is a directory containing the FAA CSV files.

let faa = Faa::from_dir(&std::path::PathBuf::from_str("./tests/data/faa").unwrap()).unwrap();
let aircraft = faa.lookup_mode_s("A44360").unwrap().unwrap();
assert_eq!(aircraft.registration, Some("N374HK".to_string()));
assert_eq!(aircraft.registrant.unwrap().name, "GENERAL ATOMICS AERONAUTICAL SYSTEMS INC".to_string());
assert_eq!(aircraft.kind, None);

// ./tests/data/mictronics is a directory containing the FAA CSV files.

let mictronics = Mictronics::from_dir(
  &std::path::PathBuf::from_str("./tests/data/mictronics").unwrap(),
)
.unwrap();
let aircraft = mictronics.lookup_mode_s("A44360").unwrap().unwrap();
assert_eq!(aircraft.registration, Some("N374HK".to_string()));
assert_eq!(aircraft.kind, Some("UHK97000-12".to_string()));

Modules§

errors
Defines an error type.
faa
Loads an FAA registration database.
mictronics
Loads a Mictronics database.

Structs§

MergeDatabase
Reg
Registration information.
Registrant
Entity an aircraft is registered to.

Enums§

Source
Possible sources of information.

Traits§

Database
Trait for looking up aircraft information.