Crates.io | ralertsinua-geo |
lib.rs | ralertsinua-geo |
version | 0.5.2 |
source | src |
created_at | 2024-05-05 19:07:32.538917 |
updated_at | 2024-05-20 20:06:35.064418 |
description | Geo compatibility layer for alerts.in.ua |
homepage | |
repository | https://github.com/voiceapiai/ralertsinua |
max_upload_size | |
id | 1230467 |
size | 131,174 |
Rust async API wrapper (reqwest) & TUI (ratatui) for alerts.in.ua
The Alerts.in.ua API Client is a Rust library that simplifies access to the alerts.in.ua API service. It provides real-time information about air raid alerts and other potential threats.
To install the Alerts.in.ua API Client, run the following command in your terminal:
cargo add ralertsinua-geo
⚠️ Before you can use this library, you need to obtain an API token by submitting an API request form.
Here's an basic example of how to use the library to get a list of active alerts:
Async:
use ralertsinua_geo::AlertsInUaGeo;
// Initialize the client
geo_client = AlertsInUaGeo();
/// The API for the AlertsInUaClient
pub trait AlertsInUaGeo: WithBoundingRect + Sync + Send + core::fmt::Debug {
fn boundary(&self) -> CountryBoundary;
fn locations(&self) -> [Location; 27];
fn get_location_by_uid(&self, uid: i32) -> Option<Location>;
fn get_location_by_name(&self, name: &str) -> Option<Location>;
}
The Location
struct represents a Ukraine's administrative unit lv4
/// Ukraine's administrative unit lv4 - *oblast*
#[derive(Debug, Deserialize, Clone, PartialEq, Serialize)]
pub struct Location {
/// OSM Relation Id
pub relation_id: String,
/// Alerts.in.ua "uid"
pub location_uid: i32,
/// "state" or "city" or "special"
pub location_type: String,
/// Geometry for boundary (Polygon or MultiPolygon)
pub geometry: Geometry,
/// Name in uk
pub name: String,
/// Name in en
pub name_en: String,
/// And some functions from traits
fn geometry(&self) -> &Geometry;
fn boundary(&self) -> &Polygon;
fn center(&self) -> (f64, f64);
/// To be used in TUI when , implements `Shape`
fn draw(&self, painter: &mut Painter);
MIT 2024
*[TUI]: Terminal User Interface