make calendar object id extrinsic

This commit is contained in:
Lennart K
2026-01-07 13:14:50 +01:00
parent 758793a11a
commit a2255bc7f1
17 changed files with 116 additions and 96 deletions

View File

@@ -62,13 +62,12 @@ impl rustical_xml::ValueDeserialize for CalendarObjectType {
#[derive(Debug, Clone)]
pub struct CalendarObject {
id: String,
inner: IcalCalendarObject,
ics: String,
}
impl CalendarObject {
pub fn from_ics(ics: String, id: Option<String>) -> Result<Self, Error> {
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)??;
@@ -78,11 +77,7 @@ impl CalendarObject {
));
}
Ok(Self {
id: id.unwrap_or_else(|| inner.get_uid().to_owned()),
inner,
ics,
})
Ok(Self { inner, ics })
}
#[must_use]
@@ -95,11 +90,6 @@ impl CalendarObject {
self.inner.get_uid()
}
#[must_use]
pub fn get_id(&self) -> &str {
&self.id
}
#[must_use]
pub fn get_etag(&self) -> String {
let mut hasher = Sha256::new();

View File

@@ -25,6 +25,6 @@ END:VCALENDAR
#[test]
fn parse_calendar_object() {
let object = CalendarObject::from_ics(MULTI_VEVENT.to_string(), None).unwrap();
let object = CalendarObject::from_ics(MULTI_VEVENT.to_string()).unwrap();
object.get_inner().expand_recurrence(None, None);
}