#[macro_use]
pub mod macros;
cfg_if::cfg_if! {
if #[cfg(feature = "nl")] {
pub mod nl;
} else {
pub mod us;
}
}
pub mod utils;
use crate::grpc::server;
use chrono::{DateTime, Utc};
use server::{FlightPlanRequest, FlightPlanResponse};
use server::{FlightReleaseRequest, FlightReleaseResponse};
use std::collections::HashMap;
use svc_gis_client_grpc::prelude::gis;
use tonic::{Request, Response, Status};
#[derive(Debug, Clone)]
pub struct RegionImpl {
pub region: String,
}
#[derive(Debug, Clone)]
pub struct RestrictionDetails {
pub vertices: Vec<gis::Coordinates>,
pub timestamp_start: Option<DateTime<Utc>>,
pub timestamp_end: Option<DateTime<Utc>>,
pub zone_type: gis::ZoneType,
pub altitude_meters_max: f32,
pub altitude_meters_min: f32,
}
#[tonic::async_trait]
pub trait RegionInterface {
fn get_region(&self) -> &str;
fn submit_flight_plan(
&self,
request: FlightPlanRequest,
) -> Result<Response<FlightPlanResponse>, Status>;
fn request_flight_release(
&self,
request: Request<FlightReleaseRequest>,
) -> Result<Response<FlightReleaseResponse>, Status>;
async fn acquire_restrictions(&self, restrictions: &mut HashMap<String, RestrictionDetails>);
async fn acquire_waypoints(&self, waypoints: &mut HashMap<String, gis::Coordinates>);
}
#[cfg(test)]
mod tests {
use super::*;
#[tokio::test]
async fn test_region_code() {
crate::get_log_handle().await;
ut_info!("(test_region_code) Start.");
let region_impl = RegionImpl::default();
cfg_if::cfg_if! {
if #[cfg(feature = "nl")] {
assert_eq!(region_impl.region, "nl");
} else {
assert_eq!(region_impl.region, "us");
}
}
ut_info!("(test_region_code) Success.");
}
}