mirror of
https://github.com/lennart-k/rustical.git
synced 2025-12-13 19:22:26 +00:00
ical: Refactor calendar object type
This commit is contained in:
@@ -63,6 +63,16 @@ pub enum CalendarObjectComponent {
|
||||
Journal(IcalJournal, Vec<IcalJournal>),
|
||||
}
|
||||
|
||||
impl From<&CalendarObjectComponent> for CalendarObjectType {
|
||||
fn from(value: &CalendarObjectComponent) -> Self {
|
||||
match value {
|
||||
CalendarObjectComponent::Event(..) => CalendarObjectType::Event,
|
||||
CalendarObjectComponent::Todo(..) => CalendarObjectType::Todo,
|
||||
CalendarObjectComponent::Journal(..) => CalendarObjectType::Journal,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
impl CalendarObjectComponent {
|
||||
fn from_events(mut events: Vec<EventObject>) -> Result<Self, Error> {
|
||||
let main_event = events
|
||||
@@ -232,11 +242,7 @@ impl CalendarObject {
|
||||
}
|
||||
|
||||
pub fn get_object_type(&self) -> CalendarObjectType {
|
||||
match self.data {
|
||||
CalendarObjectComponent::Todo(_, _) => CalendarObjectType::Todo,
|
||||
CalendarObjectComponent::Event(_, _) => CalendarObjectType::Event,
|
||||
CalendarObjectComponent::Journal(_, _) => CalendarObjectType::Journal,
|
||||
}
|
||||
(&self.data).into()
|
||||
}
|
||||
|
||||
pub fn get_first_occurence(&self) -> Result<Option<CalDateTime>, Error> {
|
||||
|
||||
Reference in New Issue
Block a user