pub struct Vatsim { /* private fields */ }Expand description
Struct containing access to the VATSIM live APIs - those listed on the VATSIM Developer Info wiki page.
Implementations§
Source§impl Vatsim
impl Vatsim
Sourcepub async fn new() -> Result<Self, VatsimUtilError>
pub async fn new() -> Result<Self, VatsimUtilError>
Create a new API struct instance.
Internally, this function also makes the API call to the status
endpoint to get the endpoint to make later API calls, which
is why this function is also async.
§Example
use vatsim_utils::live_api::Vatsim;
let api = Vatsim::new().await.unwrap();§Errors
This function can fail if the HTTP requests to the VATSIM API status endpoint fail, as this endpoint is required in order to get and store URLs to later query for getting data.
§Panics
Will panic if the HTTP user agent cannot be constructed, which should never happen.
Sourcepub async fn get_v3_data(&self) -> Result<V3ResponseData, VatsimUtilError>
pub async fn get_v3_data(&self) -> Result<V3ResponseData, VatsimUtilError>
Query the stored V3 endpoint.
This function sorts the pilots and controllers by their callsigns, alphabetically, before returning.
§Example
use vatsim_utils::live_api::Vatsim;
let api = Vatsim::new().await.unwrap();
let data = api.get_v3_data().await.unwrap();
// use data ...§Errors
This function can fail if the HTTP request fails or if the returned data does not match the schemas of the models passed to the deserializer.
§Panics
Could panic if the callsign Strings fail partial_cmp.
Sourcepub async fn get_transceivers_data(
&self,
) -> Result<Vec<TransceiverResponseEntry>, VatsimUtilError>
pub async fn get_transceivers_data( &self, ) -> Result<Vec<TransceiverResponseEntry>, VatsimUtilError>
Get pilot transceiver frequency data.
§Example
use vatsim_utils::live_api::Vatsim;
let api = Vatsim::new().await.unwrap();
let data = api.get_transceivers_data().await.unwrap();
// use data ...§Errors
This function can fail if the HTTP request fails or if the returned data does not match the schemas of the models passed to the deserializer.