add parsing for Campfire

This commit is contained in:
_ 2025-08-14 04:39:24 +00:00
parent 92c30167df
commit d789425e47
6 changed files with 263 additions and 37 deletions

View file

@ -191,17 +191,6 @@ struct RecurrenceKey<'a> {
}
impl Calendar {
pub(crate) fn read_from_str(config: Config, s: &str) -> Result<Self> {
let cal = s.parse().map_err(|s| anyhow!("parse error {s}"))?;
let cal = Self { cal, config };
Ok(cal)
}
pub(crate) fn read_from_downloadable(config: Config) -> Result<Self> {
let s = std::fs::read_to_string(&config.dl.file_path)?;
Self::read_from_str(config, &s)
}
fn events(&self) -> impl Iterator<Item = &icalendar::Event> {
self.cal.components.iter().filter_map(|comp| {
if let icalendar::CalendarComponent::Event(ev) = comp {
@ -271,4 +260,15 @@ impl Calendar {
Ok(instances)
}
pub(crate) fn read_from_str(config: Config, s: &str) -> Result<Self> {
let cal = s.parse().map_err(|s| anyhow!("parse error {s}"))?;
let cal = Self { cal, config };
Ok(cal)
}
pub(crate) fn read_from_config(config: Config) -> Result<Self> {
let s = std::fs::read_to_string(&config.dl.file_path)?;
Self::read_from_str(config, &s)
}
}