use std::io::Read; mod ics; use ics::Parser; fn fetch(client: &reqwest::Client, url: &str) -> Result<(), Box> { let mut res = client.get(url).send()?; println!("Status: {}", res.status()); println!("Headers:\n{:?}", res.headers()); let mut p = Parser::new(); let mut buf = [0; 8192]; loop { match res.read(&mut buf)? { len if len > 0 => { let data = &buf[..len]; p.feed(data, |obj| { println!("{} {}", obj.content.get("DTSTART").unwrap_or(&"?".to_owned()), obj.content.get("SUMMARY").unwrap_or(&"?".to_owned())); println!("{}", obj.content.get("LOCATION").unwrap_or(&"?".to_owned())); }); } _ => break, } } Ok(()) } fn main() { let client = reqwest::Client::new(); fetch(&client, "https://c3d2.de/ical.ics").expect("fetch"); fetch(&client, "https://www.dresden-science-calendar.de/calendar/de/iCalSync.ics").expect("fetch"); }