Spaces:
Sleeping
Sleeping
File size: 1,385 Bytes
ae32abe | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 | use serde::Serialize;
#[derive(Debug, Clone, Serialize)]
#[serde(rename_all = "camelCase")]
pub struct JobRoutesDto {
pub id: String,
pub job_id: String,
pub snapshot_revision: u64,
pub routes: Vec<TechnicianRouteGeometryDto>,
}
#[derive(Debug, Clone, Serialize)]
#[serde(rename_all = "camelCase")]
pub struct TechnicianRouteGeometryDto {
pub route_id: String,
pub technician_id: String,
pub technician_name: String,
pub color: String,
pub segments: Vec<RouteSegmentDto>,
}
#[derive(Debug, Clone, Copy, PartialEq, Eq, Serialize)]
#[serde(rename_all = "SCREAMING_SNAKE_CASE")]
pub enum RouteGeometryStatus {
Routed,
UnreachableLeg,
SnapFailed,
NoPath,
}
#[derive(Debug, Clone, Serialize)]
#[serde(rename_all = "camelCase")]
pub struct RouteSegmentDto {
pub route_id: String,
pub from_location_idx: usize,
pub to_location_idx: usize,
pub duration_seconds: i64,
pub distance_meters: i64,
pub reachable: bool,
pub geometry_status: RouteGeometryStatus,
pub encoded_polyline: String,
}
impl JobRoutesDto {
pub fn new(
job_id: usize,
snapshot_revision: u64,
routes: Vec<TechnicianRouteGeometryDto>,
) -> Self {
Self {
id: job_id.to_string(),
job_id: job_id.to_string(),
snapshot_revision,
routes,
}
}
}
|