pub mod cached_calendar; use std::convert::TryFrom; use std::error::Error; use std::collections::HashMap; use std::collections::BTreeMap; use url::Url; use serde::{Deserialize, Serialize}; use chrono::{DateTime, Utc}; use crate::Item; use crate::item::ItemId; use bitflags::bitflags; bitflags! { #[derive(Serialize, Deserialize)] pub struct SupportedComponents: u8 { /// An event, such as a calendar meeting const EVENT = 1; /// A to-do item, such as a reminder const TODO = 2; } } impl TryFrom for SupportedComponents { type Error = Box; /// Create an instance from an XML element fn try_from(element: minidom::Element) -> Result { if element.name() != "supported-calendar-component-set" { return Err("Element must be a ".into()); } let mut flags = Self::empty(); for child in element.children() { match child.attr("name") { None => continue, Some("VEVENT") => flags.insert(Self::EVENT), Some("VTODO") => flags.insert(Self::TODO), Some(other) => { log::warn!("Unimplemented supported component type: {:?}. Ignoring it", other); continue }, }; } Ok(flags) } } /// Flags to tell which events should be retrieved pub enum SearchFilter { /// Return all items All, /// Return only tasks Tasks, // /// Return only completed tasks // CompletedTasks, // /// Return only calendar events // Events, } impl Default for SearchFilter { fn default() -> Self { SearchFilter::All } }