mirror of
https://github.com/lennart-k/rustical.git
synced 2026-01-30 14:08:23 +00:00
clean up ical-related stuff
This commit is contained in:
@@ -68,14 +68,8 @@ pub struct CalendarObject {
|
||||
|
||||
impl CalendarObject {
|
||||
pub fn from_ics(ics: String) -> Result<Self, Error> {
|
||||
let mut parser: ComponentParser<_, IcalCalendarObject> =
|
||||
ComponentParser::new(ics.as_bytes());
|
||||
let inner = parser.next().ok_or(Error::MissingCalendar)??;
|
||||
if parser.next().is_some() {
|
||||
return Err(Error::InvalidData(
|
||||
"multiple calendars, only one allowed".to_owned(),
|
||||
));
|
||||
}
|
||||
let parser: ComponentParser<_, IcalCalendarObject> = ComponentParser::new(ics.as_bytes());
|
||||
let inner = parser.expect_one()?;
|
||||
|
||||
Ok(Self { inner, ics })
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user