use ical::{
component::vevent::VEVENT,
prop::{categories::CATEGORIES, geo::GEO, rdate::RDATE, request_status::REQUEST_STATUS},
tree::cst::IcalCst,
};
fn main() {
let raw = concat!(
"BEGIN:VCALENDAR\r\n",
"VERSION:2.0\r\n",
"PRODID:-//Example//EN\r\n",
"BEGIN:VEVENT\r\n",
"UID:offsite@example.com\r\n",
"DTSTAMP:20260101T000000Z\r\n",
"DTSTART:20260105T090000Z\r\n",
"GEO:37.386013;-122.082932\r\n",
"CATEGORIES:work,offsite,travel\r\n",
"RDATE:20260112T090000Z,20260119T090000Z\r\n",
"REQUEST-STATUS:2.0;Success\r\n",
"END:VEVENT\r\n",
"END:VCALENDAR\r\n",
);
let mut cst = IcalCst::parse(raw).unwrap();
let event = cst.component_mut::<VEVENT>().expect("the event");
{
let geo = event.prop_mut::<GEO>().expect("a position");
println!("GEO latitude {:?}", geo.component(0));
println!("GEO longitude {:?}", geo.component(1));
println!("GEO whole {:?}", geo.text());
}
{
let mut categories = event.prop_mut::<CATEGORIES>().expect("the categories");
println!("\nCATEGORIES {:?}", categories.list());
categories.set_list(&["work", "offsite", "travel", "quarterly"]);
println!("after adding one: {:?}", categories.list());
}
{
let dates = event.prop_mut::<RDATE>().expect("the extra dates");
println!("\nRDATE {:?}", dates.list());
}
{
let status = event.prop_mut::<REQUEST_STATUS>().expect("a status");
println!("\nREQUEST-STATUS code {:?}", status.component(0));
println!("REQUEST-STATUS description {:?}", status.component(1));
}
print!("\n{cst}");
}