fej/src/ivago/controller/structs.rs

43 lines
815 B
Rust

use std::convert::TryFrom;
/// Represents a street
pub struct Street {
name: String,
city: String,
}
impl TryFrom<&String> for Street {
type Error = ();
fn try_from(value: &String) -> Result<Self, Self::Error> {
if let Some(index) = value.find('(') {
Ok(Street {
name: (value[0 .. index - 1].trim()).to_string(),
city: (value[index + 1 .. value.len() - 1].trim()).to_string(),
})
}else {
Err(())
}
}
}
/// Represents a timezoneless date
pub struct Date {
day: u8,
month: u8,
year: u32,
}
/// Represents a pickup time instance. All fields are a direct map of the
/// original API
pub struct PickupTime {
date: Date,
label: String,
classes: Vec<String>,
url: String
}