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 restson::{Error, RestPath}; #[derive(Serialize, Deserialize, Debug, Clone, PartialEq)] pub struct StationSearch { pub name: String, pub name_exact: bool, pub country: String, pub country_excat: bool, pub state: String, pub state_exact: bool, pub language: String, pub language_exact: bool, pub tag: String, pub tag_exact: bool, pub bitrate_min: u32, pub bitrate_max: u32, pub order: String, pub reverse: bool, pub offset: u32, pub limit: u32, } impl StationSearch { pub fn new() -> Self { StationSearch { name: "".to_string(), name_exact: false, country: "".to_string(), country_excat: false, state: "".to_string(), state_exact: false, language: "".to_string(), language_exact: false, tag: "".to_string(), tag_exact: false, bitrate_min: 0, bitrate_max: 99000, order: "".to_string(), reverse: false, offset: 0, limit: 100, } } pub fn search_for_name(name: String, exact: bool, limit: u32) -> Self { let mut search = Self::new(); search.name = name; search.name_exact = exact; search.limit = limit; search } } impl RestPath<()> for StationSearch { fn get_path(_: ()) -> Result<String, Error> { Ok(String::from("webservice/json/stations/search")) } }