routee_compass/plugin/input/
input_field.rs

1use serde::{Deserialize, Serialize};
2use std::fmt::Display;
3
4#[derive(Debug, Serialize, Deserialize)]
5pub enum InputField {
6    OriginX,
7    OriginY,
8    DestinationX,
9    DestinationY,
10    OriginVertex,
11    DestinationVertex,
12    OriginEdge,
13    DestinationEdge,
14    GridSearch,
15    QueryWeightEstimate,
16    Custom(String),
17}
18
19impl InputField {
20    pub fn to_str(&self) -> &str {
21        use InputField as I;
22        match self {
23            I::OriginX => "origin_x",
24            I::OriginY => "origin_y",
25            I::DestinationX => "destination_x",
26            I::DestinationY => "destination_y",
27            I::OriginVertex => "origin_vertex",
28            I::DestinationVertex => "destination_vertex",
29            I::OriginEdge => "origin_edge",
30            I::DestinationEdge => "destination_edge",
31            I::GridSearch => "grid_search",
32            I::QueryWeightEstimate => "query_weight_estimate",
33            I::Custom(field) => field,
34        }
35    }
36}
37
38impl Display for InputField {
39    fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
40        write!(f, "{}", self.to_str())
41    }
42}