[#4] Started implementing needed traits (#4)

master
Jef Roosens 2021-04-03 22:40:22 +02:00
parent e3174f21af
commit 27a61f8a9a
Signed by: Jef Roosens
GPG Key ID: 955C0660072F691F
1 changed files with 13 additions and 0 deletions

View File

@ -1,5 +1,7 @@
use super::search::Street;
use chrono::NaiveDate;
use rocket::http::RawStr;
use rocket::request::FromFormValue;
use std::error::Error;
const BASE_URL: &str = "https://www.ivago.be/nl/particulier/afval/ophaling";
@ -13,6 +15,17 @@ pub struct PickupTime {
url: String,
}
impl<'v> FromFormValue<'v> for NaiveDate {
type Error = &'v RawStr;
fn from_form_value(form_value: &'v RawStr) -> Result<NaiveDate, &'v RawStr> {
match NaiveDate::parse_from_str(form_value, "%Y-%m-%d") {
Ok(date) => Ok(date),
Err(_) => Err(form_value),
}
}
}
pub fn get_pickup_times(
street: Street,
number: u64,