use crate::point::Point;
use crate::route::Route;
use derive_builder::Builder;
use serde::{Deserialize, Serialize};
#[derive(Debug, Clone, Copy, Default, PartialEq, Eq)]
pub enum TripSource {
#[default]
Any,
First,
}
#[derive(Debug, Clone, Copy, Default, PartialEq, Eq)]
pub enum TripDestination {
#[default]
Any,
Last,
}
#[derive(Debug, Builder, Clone, PartialEq)]
#[builder(pattern = "owned")]
pub struct TripRequest {
points: Vec<Point>,
#[builder(default = "true")]
roundtrip: bool,
#[builder(default)]
source: TripSource,
#[builder(default)]
destination: TripDestination,
#[builder(default)]
steps: bool,
}
impl TripRequest {
pub fn new(points: Vec<Point>) -> Self {
Self {
points,
roundtrip: true,
source: TripSource::Any,
destination: TripDestination::Any,
steps: false,
}
}
pub fn builder() -> TripRequestBuilder {
TripRequestBuilder::default()
}
pub fn points(&self) -> &[Point] {
&self.points
}
pub const fn roundtrip(&self) -> bool {
self.roundtrip
}
pub const fn source(&self) -> TripSource {
self.source
}
pub const fn destination(&self) -> TripDestination {
self.destination
}
pub const fn steps(&self) -> bool {
self.steps
}
}
#[derive(Debug, Clone, Deserialize, Serialize, PartialEq)]
#[non_exhaustive]
pub struct TripResponse {
pub code: String,
pub trips: Vec<Route>,
pub waypoints: Vec<TripWaypoint>,
}
#[derive(Debug, Clone, Deserialize, Serialize, PartialEq)]
#[non_exhaustive]
pub struct TripWaypoint {
pub hint: String,
pub location: [f64; 2],
pub name: String,
pub distance: f64,
pub trips_index: usize,
pub waypoint_index: usize,
}