| 1 | use std::fmt::{self, Display}; |
| 2 | use std::net::IpAddr; |
| 3 | |
| 4 | |
| 5 | #[derive (Debug, PartialEq)] |
| 6 | pub enum Query { |
| 7 | Coords(f32, f32), |
| 8 | City(String), |
| 9 | Ip(Option<IpAddr>) |
| 10 | } |
| 11 | |
| 12 | impl Display for Query { |
| 13 | fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { |
| 14 | match self { |
| 15 | Query::Coords(lat: &f32, long: &f32) => write!(f, " {lat}, {long}" ), |
| 16 | Query::City(name: &String) => write!(f, " {name}" ), |
| 17 | Query::Ip(Some(ip: &IpAddr)) => write!(f, " {ip}" ), |
| 18 | Query::Ip(None) => write!(f, "auto:ip" ) |
| 19 | } |
| 20 | } |
| 21 | } |