1
use crate::common::{
2
    CalendarDateTime, CalendarUserType, Encoding, FreeBusyTimeType, ParticipationStatusUnknown,
3
    Range, RelationshipType, Role, Status, TimeTransparency, TriggerRelationship, Value,
4
};
5
use crate::model::object::ICalObjectBuilder;
6
use crate::model::param::{
7
    add_is_utc, altrep_param, common_name_param, directory_entry_reference_param, language_param,
8
    sent_by_param, tz_id_param, CalendarUserTypeParam, DelegatedFromParam, DelegatedToParam,
9
    EncodingParam, FormatTypeParam, FreeBusyTimeTypeParam, MembersParam, ParticipationStatusParam,
10
    RangeParam, RelationshipTypeParam, RoleParam, RsvpParam, TriggerRelationshipParam,
11
    ValueTypeParam,
12
};
13
use crate::model::param::{impl_other_component_params_builder, impl_other_params_builder, Param};
14
use std::fmt::Display;
15
use std::marker::PhantomData;
16

            
17
mod duration;
18
mod recur;
19

            
20
use crate::model::impl_property_access;
21
pub use duration::*;
22
pub use recur::*;
23

            
24
pub trait AddComponentProperty {
25
    fn add_property(&mut self, property: ComponentProperty);
26
}
27

            
28
pub trait DateTimeQuery {
29
    fn is_date(&self) -> bool;
30
    fn is_local_time(&self) -> bool;
31
    fn is_utc(&self) -> bool;
32
    fn is_local_time_with_timezone(&self) -> bool;
33
}
34

            
35
macro_rules! impl_date_time_query {
36
    ($for_type:ty) => {
37
        impl DateTimeQuery for $for_type {
38
            fn is_date(&self) -> bool {
39
                self.value.is_date()
40
            }
41

            
42
            // Form 1, local date-time
43
28
            fn is_local_time(&self) -> bool {
44
28
                self.value.is_date_time()
45
28
                    && !self.value.is_utc()
46
22
                    && !self
47
22
                        .params
48
22
                        .iter()
49
26
                        .any(|p| matches!(p, Param::TimeZoneId { .. }))
50
28
            }
51

            
52
            // Form 2, UTC date-time
53
26
            fn is_utc(&self) -> bool {
54
26
                self.value.is_date_time() && self.value.is_utc()
55
26
            }
56

            
57
            // Form 3, date-time in a specific time zone
58
20
            fn is_local_time_with_timezone(&self) -> bool {
59
20
                self.value.is_date_time()
60
20
                    && self
61
20
                        .params
62
20
                        .iter()
63
24
                        .any(|p| matches!(p, Param::TimeZoneId { .. }))
64
20
            }
65
        }
66
    };
67
}
68

            
69
#[derive(Debug, Eq, PartialEq)]
70
pub enum Classification {
71
    Public,
72
    Private,
73
    Confidential,
74
    XName(String),
75
    IanaToken(String),
76
}
77

            
78
impl Display for Classification {
79
    fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
80
        let str = match self {
81
            Classification::Public => "PUBLIC".to_string(),
82
            Classification::Private => "PRIVATE".to_string(),
83
            Classification::Confidential => "CONFIDENTIAL".to_string(),
84
            Classification::XName(name) => name.to_string(),
85
            Classification::IanaToken(token) => token.to_string(),
86
        };
87
        write!(f, "{}", str)
88
    }
89
}
90

            
91
pub enum StatusEvent {
92
    Tentative,
93
    Confirmed,
94
    Cancelled,
95
}
96

            
97
impl From<StatusEvent> for Status {
98
14
    fn from(status: StatusEvent) -> Self {
99
14
        match status {
100
2
            StatusEvent::Tentative => Status::Tentative,
101
12
            StatusEvent::Confirmed => Status::Confirmed,
102
            StatusEvent::Cancelled => Status::Cancelled,
103
        }
104
14
    }
105
}
106

            
107
pub enum StatusToDo {
108
    NeedsAction,
109
    Completed,
110
    InProcess,
111
    Cancelled,
112
}
113

            
114
impl From<StatusToDo> for Status {
115
12
    fn from(status: StatusToDo) -> Self {
116
12
        match status {
117
            StatusToDo::NeedsAction => Status::NeedsAction,
118
            StatusToDo::Completed => Status::Completed,
119
12
            StatusToDo::InProcess => Status::InProcess,
120
            StatusToDo::Cancelled => Status::Cancelled,
121
        }
122
12
    }
123
}
124

            
125
pub enum StatusJournal {
126
    Draft,
127
    Final,
128
    Cancelled,
129
}
130

            
131
impl From<StatusJournal> for Status {
132
12
    fn from(status: StatusJournal) -> Self {
133
12
        match status {
134
12
            StatusJournal::Draft => Status::Draft,
135
            StatusJournal::Final => Status::Final,
136
            StatusJournal::Cancelled => Status::Cancelled,
137
        }
138
12
    }
139
}
140

            
141
macro_rules! impl_finish_property_build {
142
    ($ev:expr) => {
143
72
        pub fn finish_property(mut self) -> ICalObjectBuilder {
144
72
            self.owner.inner.properties.push($ev(self.inner));
145
72
            self.owner
146
72
        }
147
    };
148
}
149

            
150
macro_rules! impl_finish_component_property_build {
151
    ($ev:expr) => {
152
686
        pub fn finish_property(mut self) -> P {
153
686
            self.owner.add_property($ev(self.inner));
154
686
            self.owner
155
686
        }
156
    };
157
}
158

            
159
#[derive(Debug, PartialEq)]
160
pub enum CalendarProperty {
161
    ProductId(ProductIdProperty),
162
    Version(VersionProperty),
163
    CalendarScale(CalendarScaleProperty),
164
    Method(MethodProperty),
165
    XProperty(XProperty),
166
    IanaProperty(IanaProperty),
167
}
168

            
169
#[derive(Debug, PartialEq)]
170
pub struct ProductIdProperty {
171
    pub(crate) value: String,
172
    pub(crate) params: Vec<Param>,
173
}
174

            
175
pub struct ProductIdPropertyBuilder {
176
    owner: ICalObjectBuilder,
177
    inner: ProductIdProperty,
178
}
179

            
180
impl ProductIdPropertyBuilder {
181
22
    pub(crate) fn new(owner: ICalObjectBuilder, value: String) -> ProductIdPropertyBuilder {
182
22
        ProductIdPropertyBuilder {
183
22
            owner,
184
22
            inner: ProductIdProperty {
185
22
                value,
186
22
                params: Vec::new(),
187
22
            },
188
22
        }
189
22
    }
190

            
191
    impl_finish_property_build!(CalendarProperty::ProductId);
192
}
193

            
194
impl_other_params_builder!(ProductIdPropertyBuilder);
195

            
196
#[derive(Debug, PartialEq)]
197
pub struct VersionProperty {
198
    pub(crate) min_version: Option<String>,
199
    pub(crate) max_version: String,
200
    pub(crate) params: Vec<Param>,
201
}
202

            
203
pub struct VersionPropertyBuilder {
204
    owner: ICalObjectBuilder,
205
    inner: VersionProperty,
206
}
207

            
208
impl VersionPropertyBuilder {
209
18
    pub(crate) fn new(
210
18
        owner: ICalObjectBuilder,
211
18
        min_version: Option<String>,
212
18
        max_version: String,
213
18
    ) -> VersionPropertyBuilder {
214
18
        VersionPropertyBuilder {
215
18
            owner,
216
18
            inner: VersionProperty {
217
18
                min_version,
218
18
                max_version,
219
18
                params: Vec::new(),
220
18
            },
221
18
        }
222
18
    }
223

            
224
    impl_finish_property_build!(CalendarProperty::Version);
225
}
226

            
227
impl_other_params_builder!(VersionPropertyBuilder);
228

            
229
#[derive(Debug, PartialEq)]
230
pub struct CalendarScaleProperty {
231
    pub(crate) value: String,
232
    pub(crate) params: Vec<Param>,
233
}
234

            
235
pub struct CalendarScalePropertyBuilder {
236
    owner: ICalObjectBuilder,
237
    inner: CalendarScaleProperty,
238
}
239

            
240
impl CalendarScalePropertyBuilder {
241
14
    pub(crate) fn new(owner: ICalObjectBuilder, value: String) -> CalendarScalePropertyBuilder {
242
14
        CalendarScalePropertyBuilder {
243
14
            owner,
244
14
            inner: CalendarScaleProperty {
245
14
                value,
246
14
                params: Vec::new(),
247
14
            },
248
14
        }
249
14
    }
250

            
251
    impl_finish_property_build!(CalendarProperty::CalendarScale);
252
}
253

            
254
impl_other_params_builder!(CalendarScalePropertyBuilder);
255

            
256
#[derive(Debug, PartialEq)]
257
pub struct MethodProperty {
258
    pub(crate) value: String,
259
    pub(crate) params: Vec<Param>,
260
}
261

            
262
pub struct MethodPropertyBuilder {
263
    owner: ICalObjectBuilder,
264
    inner: MethodProperty,
265
}
266

            
267
impl MethodPropertyBuilder {
268
14
    pub(crate) fn new(owner: ICalObjectBuilder, value: String) -> MethodPropertyBuilder {
269
14
        MethodPropertyBuilder {
270
14
            owner,
271
14
            inner: MethodProperty {
272
14
                params: Vec::new(),
273
14
                value,
274
14
            },
275
14
        }
276
14
    }
277

            
278
    impl_finish_property_build!(CalendarProperty::Method);
279
}
280

            
281
impl_other_params_builder!(MethodPropertyBuilder);
282

            
283
#[derive(Debug, PartialEq)]
284
pub enum ComponentProperty {
285
    /// RFC 5545, 3.8.1.1
286
    /// Value type: URI or BINARY
287
    Attach(AttachProperty),
288
    /// RFC 5545, 3.8.1.2
289
    /// Value type: TEXT
290
    Categories(CategoriesProperty),
291
    /// RFC 5545, 3.8.1.3
292
    /// Value type: TEXT
293
    Classification(ClassificationProperty),
294
    /// RFC 5545, 3.8.1.4
295
    /// Value type: TEXT
296
    Comment(CommentProperty),
297
    /// RFC 5545, 3.8.1.5
298
    /// Value type: TEXT
299
    Description(DescriptionProperty),
300
    /// RFC 5545, 3.8.1.6
301
    /// Value type: FLOAT
302
    GeographicPosition(GeographicPositionProperty),
303
    /// RFC 5545, 3.8.1.7
304
    /// Value type: TEXT
305
    Location(LocationProperty),
306
    /// RFC 5545, 4.8.1.8
307
    /// Value type: INTEGER
308
    PercentComplete(PercentCompleteProperty),
309
    /// RFC 5545, 3.8.1.9
310
    /// Value type: INTEGER
311
    Priority(PriorityProperty),
312
    /// RFC 5545, 3.8.1.10
313
    /// Value type: TEXT
314
    Resources(ResourcesProperty),
315
    /// RFC 5545, 3.8.1.11
316
    /// Value type: TEXT
317
    Status(StatusProperty),
318
    /// RFC 5545, 3.8.1.12
319
    /// Value type: TEXT
320
    Summary(SummaryProperty),
321
    /// RFC 5545, 3.8.2.1
322
    /// Value type: DATE-TIME
323
    DateTimeCompleted(DateTimeCompletedProperty),
324
    /// RFC 5545, 3.8.2.2
325
    /// Value type: DATE-TIME or DATE
326
    DateTimeEnd(DateTimeEndProperty),
327
    /// RFC 5545, 3.8.2.3
328
    /// Value type: DATE-TIME or DATE
329
    DateTimeDue(DateTimeDueProperty),
330
    /// RFC 5545, 3.8.2.4
331
    /// Value type: DATE-TIME or DATE
332
    DateTimeStart(DateTimeStartProperty),
333
    /// RFC 5545, 3.8.2.5
334
    /// Value type: DURATION
335
    Duration(DurationProperty),
336
    /// RFC 5545, 3.8.2.6
337
    /// Value type: PERIOD
338
    FreeBusyTime(FreeBusyTimeProperty),
339
    /// RFC 5545, 3.8.2.7
340
    /// Value type: TEXT
341
    TimeTransparency(TimeTransparencyProperty),
342
    /// RFC 5545, 3.8.3.1
343
    /// Value type: TEXT
344
    TimeZoneId(TimeZoneIdProperty),
345
    /// RFC 5545, 3.8.3.2
346
    /// Value type: TEXT
347
    TimeZoneName(TimeZoneNameProperty),
348
    /// RFC 5545, 3.8.3.3
349
    /// Value type: UTC-OFFSET
350
    TimeZoneOffsetFrom(TimeZoneOffsetFromProperty),
351
    /// RFC 5545, 3.8.3.4
352
    /// Value type: UTC-OFFSET
353
    TimeZoneOffsetTo(TimeZoneOffsetToProperty),
354
    /// RFC 5545, 3.8.3.5
355
    /// Value type: URI
356
    TimeZoneUrl(TimeZoneUrlProperty),
357
    /// RFC 5545, 3.8.4.1
358
    /// Value type: CAL-ADDRESS
359
    Attendee(AttendeeProperty),
360
    /// RFC 5545, 3.8.4.2
361
    /// Value type: TEXT
362
    Contact(ContactProperty),
363
    /// RFC 5545, 3.8.4.3
364
    /// Value type: CAL-ADDRESS
365
    Organizer(OrganizerProperty),
366
    /// RFC 5545, 3.8.4.4
367
    /// Value type: DATE-TIME or DATE
368
    RecurrenceId(RecurrenceIdProperty),
369
    /// RFC 5545, 3.8.4.5
370
    /// Value type: TEXT
371
    RelatedTo(RelatedToProperty),
372
    /// RFC 5545, 3.8.4.6
373
    /// Value type: URI
374
    Url(UrlProperty),
375
    /// RFC 5545, 3.8.4.7
376
    /// Value type: TEXT
377
    UniqueIdentifier(UniqueIdentifierProperty),
378
    /// RFC 5545, 3.8.5.1
379
    /// Value type: DATE-TIME or DATE
380
    ExceptionDateTimes(ExceptionDateTimesProperty),
381
    /// RFC 5545, 3.8.5.2
382
    /// Value type: DATE-TIME or DATE or PERIOD
383
    RecurrenceDateTimes(RecurrenceDateTimesProperty),
384
    /// RFC 5545, 3.8.5.3
385
    /// Value type: RECUR
386
    RecurrenceRule(RecurrenceRuleProperty),
387
    /// RFC 5545, 3.8.6.1
388
    /// Value type: TEXT
389
    Action(ActionProperty),
390
    /// RFC 5545, 3.8.6.2
391
    /// Value type: INTEGER
392
    Repeat(RepeatProperty),
393
    /// RFC 5545, 3.8.6.3
394
    /// Value type: DURATION or DATE-TIME
395
    Trigger(TriggerProperty),
396
    /// RFC 5545, 3.8.7.1
397
    /// Value type: DATE-TIME
398
    DateTimeCreated(CreatedProperty),
399
    /// RFC 5545, 3.8.7.2
400
    /// Value type: DATE-TIME
401
    DateTimeStamp(DateTimeStampProperty),
402
    /// RFC 5545, 3.8.7.3
403
    /// Value type: DATE-TIME
404
    LastModified(LastModifiedProperty),
405
    /// RFC 5545, 3.8.7.4
406
    /// Value type: INTEGER
407
    Sequence(SequenceProperty),
408
    /// RFC 5545, 3.8.8.1
409
    /// Value type: TEXT or any other type
410
    IanaProperty(IanaProperty),
411
    /// RFC 5545, 3.8.8.2
412
    /// Value type: TEXT or any other type
413
    XProperty(XProperty),
414
    /// RFC 5545, 3.8.8.3
415
    /// Value type: TEXT
416
    RequestStatus(RequestStatusProperty),
417
}
418

            
419
impl ComponentProperty {
420
2280
    pub fn params(&self) -> &[Param] {
421
2280
        match self {
422
158
            ComponentProperty::DateTimeStamp(p) => &p.params,
423
158
            ComponentProperty::UniqueIdentifier(p) => &p.params,
424
170
            ComponentProperty::DateTimeStart(p) => &p.params,
425
36
            ComponentProperty::Classification(p) => &p.params,
426
36
            ComponentProperty::DateTimeCreated(p) => &p.params,
427
96
            ComponentProperty::Description(p) => &p.params,
428
20
            ComponentProperty::GeographicPosition(p) => &p.params,
429
42
            ComponentProperty::LastModified(p) => &p.params,
430
26
            ComponentProperty::Location(p) => &p.params,
431
48
            ComponentProperty::Organizer(p) => &p.params,
432
20
            ComponentProperty::Priority(p) => &p.params,
433
30
            ComponentProperty::Sequence(p) => &p.params,
434
48
            ComponentProperty::Summary(p) => &p.params,
435
10
            ComponentProperty::TimeTransparency(p) => &p.params,
436
24
            ComponentProperty::RequestStatus(p) => &p.params,
437
40
            ComponentProperty::Url(p) => &p.params,
438
30
            ComponentProperty::RecurrenceId(p) => &p.params,
439
176
            ComponentProperty::RecurrenceRule(p) => &p.params,
440
44
            ComponentProperty::DateTimeEnd(p) => &p.params,
441
62
            ComponentProperty::Duration(p) => &p.params,
442
54
            ComponentProperty::Attach(p) => &p.params,
443
40
            ComponentProperty::Attendee(p) => &p.params,
444
24
            ComponentProperty::Categories(p) => &p.params,
445
36
            ComponentProperty::Comment(p) => &p.params,
446
28
            ComponentProperty::Contact(p) => &p.params,
447
20
            ComponentProperty::ExceptionDateTimes(p) => &p.params,
448
30
            ComponentProperty::Status(p) => &p.params,
449
18
            ComponentProperty::RelatedTo(p) => &p.params,
450
12
            ComponentProperty::Resources(p) => &p.params,
451
64
            ComponentProperty::RecurrenceDateTimes(p) => &p.params,
452
6
            ComponentProperty::DateTimeCompleted(p) => &p.params,
453
10
            ComponentProperty::PercentComplete(p) => &p.params,
454
10
            ComponentProperty::DateTimeDue(p) => &p.params,
455
6
            ComponentProperty::FreeBusyTime(p) => &p.params,
456
26
            ComponentProperty::TimeZoneId(p) => &p.params,
457
10
            ComponentProperty::TimeZoneUrl(p) => &p.params,
458
40
            ComponentProperty::TimeZoneOffsetTo(p) => &p.params,
459
40
            ComponentProperty::TimeZoneOffsetFrom(p) => &p.params,
460
30
            ComponentProperty::TimeZoneName(p) => &p.params,
461
52
            ComponentProperty::Action(p) => &p.params,
462
92
            ComponentProperty::Trigger(p) => &p.params,
463
42
            ComponentProperty::Repeat(p) => &p.params,
464
168
            ComponentProperty::IanaProperty(p) => &p.params,
465
148
            ComponentProperty::XProperty(p) => &p.params,
466
        }
467
2280
    }
468
}
469

            
470
pub trait ComponentPropertyInner<T> {
471
    fn property_inner(&self) -> Option<&T>;
472
}
473

            
474
macro_rules! impl_component_property_inner {
475
    ($for_type:ty, $variant:ident) => {
476
        impl $crate::model::property::ComponentPropertyInner<$for_type>
477
            for $crate::model::property::ComponentProperty
478
        {
479
114
            fn property_inner(&self) -> Option<&$for_type> {
480
114
                match self {
481
48
                    $crate::model::property::ComponentProperty::$variant(p) => Some(p),
482
66
                    _ => None,
483
                }
484
114
            }
485
        }
486
    };
487
}
488

            
489
impl_component_property_inner!(ClassificationProperty, Classification);
490
impl_component_property_inner!(DescriptionProperty, Description);
491
impl_component_property_inner!(GeographicPositionProperty, GeographicPosition);
492
impl_component_property_inner!(LocationProperty, Location);
493
impl_component_property_inner!(PercentCompleteProperty, PercentComplete);
494
impl_component_property_inner!(PriorityProperty, Priority);
495
impl_component_property_inner!(StatusProperty, Status);
496
impl_component_property_inner!(SummaryProperty, Summary);
497
impl_component_property_inner!(DateTimeCompletedProperty, DateTimeCompleted);
498
impl_component_property_inner!(DateTimeEndProperty, DateTimeEnd);
499
impl_component_property_inner!(DateTimeDueProperty, DateTimeDue);
500
impl_component_property_inner!(DateTimeStartProperty, DateTimeStart);
501
impl_component_property_inner!(DurationProperty, Duration);
502
impl_component_property_inner!(TimeTransparencyProperty, TimeTransparency);
503
impl_component_property_inner!(TimeZoneIdProperty, TimeZoneId);
504
impl_component_property_inner!(TimeZoneOffsetFromProperty, TimeZoneOffsetFrom);
505
impl_component_property_inner!(TimeZoneOffsetToProperty, TimeZoneOffsetTo);
506
impl_component_property_inner!(TimeZoneUrlProperty, TimeZoneUrl);
507
impl_component_property_inner!(OrganizerProperty, Organizer);
508
impl_component_property_inner!(RecurrenceIdProperty, RecurrenceId);
509
impl_component_property_inner!(UrlProperty, Url);
510
impl_component_property_inner!(UniqueIdentifierProperty, UniqueIdentifier);
511
impl_component_property_inner!(RecurrenceRuleProperty, RecurrenceRule);
512
impl_component_property_inner!(ActionProperty, Action);
513
impl_component_property_inner!(RepeatProperty, Repeat);
514
impl_component_property_inner!(TriggerProperty, Trigger);
515
impl_component_property_inner!(CreatedProperty, DateTimeCreated);
516
impl_component_property_inner!(DateTimeStampProperty, DateTimeStamp);
517
impl_component_property_inner!(LastModifiedProperty, LastModified);
518
impl_component_property_inner!(SequenceProperty, Sequence);
519
impl_component_property_inner!(ContactProperty, Contact);
520
impl_component_property_inner!(AttachProperty, Attach);
521

            
522
pub trait ComponentPropertiesInner<T> {
523
    fn many_property_inner(&self) -> Option<&T>;
524
}
525

            
526
macro_rules! impl_component_properties_inner {
527
    ($for_type:ty, $variant:ident) => {
528
        impl $crate::model::property::ComponentPropertiesInner<$for_type>
529
            for $crate::model::property::ComponentProperty
530
        {
531
312
            fn many_property_inner(&self) -> Option<&$for_type> {
532
312
                match self {
533
18
                    $crate::model::property::ComponentProperty::$variant(p) => Some(p),
534
294
                    _ => None,
535
                }
536
312
            }
537
        }
538
    };
539
}
540

            
541
impl_component_properties_inner!(AttachProperty, Attach);
542
impl_component_properties_inner!(CategoriesProperty, Categories);
543
impl_component_properties_inner!(AttendeeProperty, Attendee);
544
impl_component_properties_inner!(RecurrenceRuleProperty, RecurrenceRule);
545
impl_component_properties_inner!(CommentProperty, Comment);
546
impl_component_properties_inner!(ContactProperty, Contact);
547
impl_component_properties_inner!(ExceptionDateTimesProperty, ExceptionDateTimes);
548
impl_component_properties_inner!(RecurrenceDateTimesProperty, RecurrenceDateTimes);
549
impl_component_properties_inner!(RequestStatusProperty, RequestStatus);
550
impl_component_properties_inner!(RelatedToProperty, RelatedTo);
551
impl_component_properties_inner!(ResourcesProperty, Resources);
552
impl_component_properties_inner!(DescriptionProperty, Description);
553
impl_component_properties_inner!(FreeBusyTimeProperty, FreeBusyTime);
554
impl_component_properties_inner!(TimeZoneNameProperty, TimeZoneName);
555

            
556
#[derive(Debug, PartialEq)]
557
pub struct TriggerProperty {
558
    pub(crate) value: TriggerValue,
559
    pub(crate) params: Vec<Param>,
560
}
561

            
562
#[derive(Debug, PartialEq)]
563
pub enum TriggerValue {
564
    Relative(Duration),
565
    Absolute(CalendarDateTime),
566
}
567

            
568
impl_property_access!(TriggerProperty, TriggerValue);
569

            
570
#[derive(Debug, PartialEq)]
571
pub struct XProperty {
572
    pub(crate) name: String,
573
    pub(crate) value: String,
574
    pub(crate) params: Vec<Param>,
575
}
576

            
577
impl_property_access!(XProperty, String);
578

            
579
pub struct XPropertyBuilder {
580
    owner: ICalObjectBuilder,
581
    inner: XProperty,
582
}
583

            
584
impl XPropertyBuilder {
585
2
    pub(crate) fn new(owner: ICalObjectBuilder, name: String, value: String) -> XPropertyBuilder {
586
2
        XPropertyBuilder {
587
2
            owner,
588
2
            inner: XProperty {
589
2
                name,
590
2
                value,
591
2
                params: Vec::new(),
592
2
            },
593
2
        }
594
2
    }
595

            
596
    impl_finish_property_build!(CalendarProperty::XProperty);
597
}
598

            
599
impl_other_params_builder!(XPropertyBuilder);
600

            
601
#[derive(Debug, PartialEq)]
602
pub struct IanaProperty {
603
    pub(crate) name: String,
604
    pub(crate) value: String,
605
    pub(crate) params: Vec<Param>,
606
}
607

            
608
impl_property_access!(IanaProperty, String);
609

            
610
pub struct IanaPropertyBuilder {
611
    owner: ICalObjectBuilder,
612
    inner: IanaProperty,
613
}
614

            
615
impl IanaPropertyBuilder {
616
2
    pub(crate) fn new(
617
2
        owner: ICalObjectBuilder,
618
2
        name: String,
619
2
        value: String,
620
2
    ) -> IanaPropertyBuilder {
621
2
        IanaPropertyBuilder {
622
2
            owner,
623
2
            inner: IanaProperty {
624
2
                name,
625
2
                value,
626
2
                params: Vec::new(),
627
2
            },
628
2
        }
629
2
    }
630

            
631
    impl_finish_property_build!(CalendarProperty::IanaProperty);
632
}
633

            
634
impl_other_params_builder!(IanaPropertyBuilder);
635

            
636
pub struct XComponentPropertyBuilder<P> {
637
    owner: P,
638
    inner: XProperty,
639
}
640

            
641
impl<P> XComponentPropertyBuilder<P>
642
where
643
    P: AddComponentProperty,
644
{
645
56
    pub(crate) fn new(owner: P, name: String, value: String) -> XComponentPropertyBuilder<P> {
646
56
        XComponentPropertyBuilder {
647
56
            owner,
648
56
            inner: XProperty {
649
56
                params: Vec::new(),
650
56
                name,
651
56
                value,
652
56
            },
653
56
        }
654
56
    }
655

            
656
    impl_finish_component_property_build!(ComponentProperty::XProperty);
657
}
658

            
659
impl_other_component_params_builder!(XComponentPropertyBuilder<P>);
660

            
661
pub struct IanaComponentPropertyBuilder<P> {
662
    owner: P,
663
    inner: IanaProperty,
664
}
665

            
666
impl<P> IanaComponentPropertyBuilder<P>
667
where
668
    P: AddComponentProperty,
669
{
670
56
    pub(crate) fn new(owner: P, name: String, value: String) -> IanaComponentPropertyBuilder<P> {
671
56
        IanaComponentPropertyBuilder {
672
56
            owner,
673
56
            inner: IanaProperty {
674
56
                name,
675
56
                value,
676
56
                params: Vec::new(),
677
56
            },
678
56
        }
679
56
    }
680

            
681
    impl_finish_component_property_build!(ComponentProperty::IanaProperty);
682
}
683

            
684
impl_other_component_params_builder!(IanaComponentPropertyBuilder<P>);
685

            
686
#[derive(Debug, PartialEq)]
687
pub struct DateTimeStampProperty {
688
    pub(crate) value: CalendarDateTime,
689
    pub(crate) params: Vec<Param>,
690
}
691

            
692
impl_property_access!(DateTimeStampProperty, CalendarDateTime);
693

            
694
pub struct DateTimeStampPropertyBuilder<P: AddComponentProperty> {
695
    owner: P,
696
    inner: DateTimeStampProperty,
697
}
698

            
699
impl<P> DateTimeStampPropertyBuilder<P>
700
where
701
    P: AddComponentProperty,
702
{
703
50
    pub(crate) fn new(
704
50
        owner: P,
705
50
        date: time::Date,
706
50
        time: time::Time,
707
50
    ) -> DateTimeStampPropertyBuilder<P> {
708
50
        DateTimeStampPropertyBuilder {
709
50
            owner,
710
50
            inner: DateTimeStampProperty {
711
50
                value: (date, time, false).into(),
712
50
                params: Vec::new(),
713
50
            },
714
50
        }
715
50
    }
716

            
717
    add_is_utc!();
718

            
719
    impl_finish_component_property_build!(ComponentProperty::DateTimeStamp);
720
}
721

            
722
impl_other_component_params_builder!(DateTimeStampPropertyBuilder<P>);
723

            
724
#[derive(Debug, PartialEq)]
725
pub struct UniqueIdentifierProperty {
726
    pub(crate) value: String,
727
    pub(crate) params: Vec<Param>,
728
}
729

            
730
impl_property_access!(UniqueIdentifierProperty, String);
731

            
732
pub struct UniqueIdentifierPropertyBuilder<P: AddComponentProperty> {
733
    owner: P,
734
    inner: UniqueIdentifierProperty,
735
}
736

            
737
impl<P> UniqueIdentifierPropertyBuilder<P>
738
where
739
    P: AddComponentProperty,
740
{
741
18
    pub(crate) fn new(owner: P, value: String) -> UniqueIdentifierPropertyBuilder<P> {
742
18
        UniqueIdentifierPropertyBuilder {
743
18
            owner,
744
18
            inner: UniqueIdentifierProperty {
745
18
                value,
746
18
                params: Vec::new(),
747
18
            },
748
18
        }
749
18
    }
750

            
751
    impl_finish_component_property_build!(ComponentProperty::UniqueIdentifier);
752
}
753

            
754
impl_other_component_params_builder!(UniqueIdentifierPropertyBuilder<P>);
755

            
756
#[derive(Debug, Clone, PartialEq)]
757
pub struct DateTimeStartProperty {
758
    pub(crate) value: CalendarDateTime,
759
    pub(crate) params: Vec<Param>,
760
}
761

            
762
impl_property_access!(DateTimeStartProperty, CalendarDateTime);
763

            
764
pub struct DateTimeStartPropertyBuilder<P: AddComponentProperty> {
765
    owner: P,
766
    inner: DateTimeStartProperty,
767
}
768

            
769
impl<P> DateTimeStartPropertyBuilder<P>
770
where
771
    P: AddComponentProperty,
772
{
773
74
    pub(crate) fn new(
774
74
        owner: P,
775
74
        date: time::Date,
776
74
        time: Option<time::Time>,
777
74
    ) -> DateTimeStartPropertyBuilder<P> {
778
74
        let mut params = Vec::new();
779
74

            
780
74
        // The default is DATE-TIME. If the time is None, then it is a DATE and although it's
781
74
        // optional, this will default to setting the value here.
782
74
        if time.is_none() {
783
            params.push(Param::ValueType(ValueTypeParam { value: Value::Date }))
784
74
        }
785

            
786
74
        DateTimeStartPropertyBuilder {
787
74
            owner,
788
74
            inner: DateTimeStartProperty {
789
74
                value: (date, time, false).into(),
790
74
                params,
791
74
            },
792
74
        }
793
74
    }
794

            
795
    tz_id_param!();
796

            
797
    add_is_utc!();
798

            
799
    impl_finish_component_property_build!(ComponentProperty::DateTimeStart);
800
}
801

            
802
impl_other_component_params_builder!(DateTimeStartPropertyBuilder<P>);
803

            
804
impl_date_time_query!(DateTimeStartProperty);
805

            
806
#[derive(Debug, PartialEq)]
807
pub struct ClassificationProperty {
808
    pub(crate) value: Classification,
809
    pub(crate) params: Vec<Param>,
810
}
811

            
812
impl_property_access!(ClassificationProperty, Classification);
813

            
814
pub struct ClassificationPropertyBuilder<P: AddComponentProperty> {
815
    owner: P,
816
    inner: ClassificationProperty,
817
}
818

            
819
impl<P> ClassificationPropertyBuilder<P>
820
where
821
    P: AddComponentProperty,
822
{
823
38
    pub(crate) fn new(owner: P, value: Classification) -> ClassificationPropertyBuilder<P> {
824
38
        ClassificationPropertyBuilder {
825
38
            owner,
826
38
            inner: ClassificationProperty {
827
38
                value,
828
38
                params: Vec::new(),
829
38
            },
830
38
        }
831
38
    }
832

            
833
    impl_finish_component_property_build!(ComponentProperty::Classification);
834
}
835

            
836
impl_other_component_params_builder!(ClassificationPropertyBuilder<P>);
837

            
838
#[derive(Debug, PartialEq)]
839
pub struct CreatedProperty {
840
    pub(crate) value: CalendarDateTime,
841
    pub(crate) params: Vec<Param>,
842
}
843

            
844
impl_property_access!(CreatedProperty, CalendarDateTime);
845

            
846
pub struct CreatedPropertyBuilder<P: AddComponentProperty> {
847
    owner: P,
848
    inner: CreatedProperty,
849
}
850

            
851
impl<P> CreatedPropertyBuilder<P>
852
where
853
    P: AddComponentProperty,
854
{
855
38
    pub(crate) fn new(owner: P, date: time::Date, time: time::Time) -> CreatedPropertyBuilder<P> {
856
38
        CreatedPropertyBuilder {
857
38
            owner,
858
38
            inner: CreatedProperty {
859
38
                value: (date, time, false).into(),
860
38
                params: Vec::new(),
861
38
            },
862
38
        }
863
38
    }
864

            
865
    add_is_utc!();
866

            
867
    impl_finish_component_property_build!(ComponentProperty::DateTimeCreated);
868
}
869

            
870
impl_other_component_params_builder!(CreatedPropertyBuilder<P>);
871

            
872
#[derive(Debug, PartialEq)]
873
pub struct DescriptionProperty {
874
    pub(crate) value: String,
875
    pub(crate) params: Vec<Param>,
876
}
877

            
878
impl_property_access!(DescriptionProperty, String);
879

            
880
pub struct DescriptionPropertyBuilder<P: AddComponentProperty> {
881
    owner: P,
882
    inner: DescriptionProperty,
883
}
884

            
885
impl<P> DescriptionPropertyBuilder<P>
886
where
887
    P: AddComponentProperty,
888
{
889
26
    pub(crate) fn new(owner: P, value: String) -> DescriptionPropertyBuilder<P> {
890
26
        DescriptionPropertyBuilder {
891
26
            owner,
892
26
            inner: DescriptionProperty {
893
26
                value,
894
26
                params: Vec::new(),
895
26
            },
896
26
        }
897
26
    }
898

            
899
    altrep_param!();
900
    language_param!();
901

            
902
    impl_finish_component_property_build!(ComponentProperty::Description);
903
}
904

            
905
impl_other_component_params_builder!(DescriptionPropertyBuilder<P>);
906

            
907
#[derive(Debug, PartialEq)]
908
pub struct GeographicPositionProperty {
909
    pub(crate) value: GeographicPositionPropertyValue,
910
    pub(crate) params: Vec<Param>,
911
}
912

            
913
#[derive(Debug, PartialEq)]
914
pub struct GeographicPositionPropertyValue {
915
    pub latitude: f64,
916
    pub longitude: f64,
917
}
918

            
919
impl_property_access!(GeographicPositionProperty, GeographicPositionPropertyValue);
920

            
921
pub struct GeographicPositionPropertyBuilder<P: AddComponentProperty> {
922
    owner: P,
923
    inner: GeographicPositionProperty,
924
}
925

            
926
impl<P> GeographicPositionPropertyBuilder<P>
927
where
928
    P: AddComponentProperty,
929
{
930
26
    pub(crate) fn new(
931
26
        owner: P,
932
26
        latitude: f64,
933
26
        longitude: f64,
934
26
    ) -> GeographicPositionPropertyBuilder<P> {
935
26
        GeographicPositionPropertyBuilder {
936
26
            owner,
937
26
            inner: GeographicPositionProperty {
938
26
                value: GeographicPositionPropertyValue {
939
26
                    latitude,
940
26
                    longitude,
941
26
                },
942
26
                params: Vec::new(),
943
26
            },
944
26
        }
945
26
    }
946

            
947
    impl_finish_component_property_build!(ComponentProperty::GeographicPosition);
948
}
949

            
950
impl_other_component_params_builder!(GeographicPositionPropertyBuilder<P>);
951

            
952
#[derive(Debug, PartialEq)]
953
pub struct LastModifiedProperty {
954
    pub(crate) value: CalendarDateTime,
955
    pub(crate) params: Vec<Param>,
956
}
957

            
958
impl_property_access!(LastModifiedProperty, CalendarDateTime);
959

            
960
pub struct LastModifiedPropertyBuilder<P: AddComponentProperty> {
961
    owner: P,
962
    inner: LastModifiedProperty,
963
}
964

            
965
impl<P> LastModifiedPropertyBuilder<P>
966
where
967
    P: AddComponentProperty,
968
{
969
50
    pub(crate) fn new(
970
50
        owner: P,
971
50
        date: time::Date,
972
50
        time: time::Time,
973
50
    ) -> LastModifiedPropertyBuilder<P> {
974
50
        LastModifiedPropertyBuilder {
975
50
            owner,
976
50
            inner: LastModifiedProperty {
977
50
                value: (date, time, false).into(),
978
50
                params: Vec::new(),
979
50
            },
980
50
        }
981
50
    }
982

            
983
    add_is_utc!();
984

            
985
    impl_finish_component_property_build!(ComponentProperty::LastModified);
986
}
987

            
988
impl_other_component_params_builder!(LastModifiedPropertyBuilder<P>);
989

            
990
#[derive(Debug, PartialEq)]
991
pub struct LocationProperty {
992
    pub(crate) value: String,
993
    pub(crate) params: Vec<Param>,
994
}
995

            
996
impl_property_access!(LocationProperty, String);
997

            
998
pub struct LocationPropertyBuilder<P: AddComponentProperty> {
999
    owner: P,
    inner: LocationProperty,
}
impl<P> LocationPropertyBuilder<P>
where
    P: AddComponentProperty,
{
24
    pub(crate) fn new(owner: P, value: String) -> LocationPropertyBuilder<P> {
24
        LocationPropertyBuilder {
24
            owner,
24
            inner: LocationProperty {
24
                value,
24
                params: Vec::new(),
24
            },
24
        }
24
    }
    altrep_param!();
    language_param!();
    impl_finish_component_property_build!(ComponentProperty::Location);
}
impl_other_component_params_builder!(LocationPropertyBuilder<P>);
#[derive(Debug, PartialEq)]
pub struct OrganizerProperty {
    pub(crate) value: String,
    pub(crate) params: Vec<Param>,
}
impl_property_access!(OrganizerProperty, String);
pub struct OrganizerPropertyBuilder<P: AddComponentProperty> {
    owner: P,
    inner: OrganizerProperty,
}
impl<P> OrganizerPropertyBuilder<P>
where
    P: AddComponentProperty,
{
50
    pub(crate) fn new(owner: P, value: String) -> OrganizerPropertyBuilder<P> {
50
        OrganizerPropertyBuilder {
50
            owner,
50
            inner: OrganizerProperty {
50
                value,
50
                params: Vec::new(),
50
            },
50
        }
50
    }
    common_name_param!();
    directory_entry_reference_param!();
    sent_by_param!();
    language_param!();
    impl_finish_component_property_build!(ComponentProperty::Organizer);
}
impl_other_component_params_builder!(OrganizerPropertyBuilder<P>);
#[derive(Debug, PartialEq)]
pub struct PriorityProperty {
    pub(crate) value: u8,
    pub(crate) params: Vec<Param>,
}
impl_property_access!(PriorityProperty, u8);
pub struct PriorityPropertyBuilder<P: AddComponentProperty> {
    owner: P,
    inner: PriorityProperty,
}
impl<P> PriorityPropertyBuilder<P>
where
    P: AddComponentProperty,
{
26
    pub(crate) fn new(owner: P, value: u8) -> PriorityPropertyBuilder<P> {
26
        PriorityPropertyBuilder {
26
            owner,
26
            inner: PriorityProperty {
26
                value,
26
                params: Vec::new(),
26
            },
26
        }
26
    }
    impl_finish_component_property_build!(ComponentProperty::Priority);
}
impl_other_component_params_builder!(PriorityPropertyBuilder<P>);
#[derive(Debug, PartialEq)]
pub struct SequenceProperty {
    pub(crate) value: u32,
    pub(crate) params: Vec<Param>,
}
impl_property_access!(SequenceProperty, u32);
pub struct SequencePropertyBuilder<P: AddComponentProperty> {
    owner: P,
    inner: SequenceProperty,
}
impl<P> SequencePropertyBuilder<P>
where
    P: AddComponentProperty,
{
38
    pub(crate) fn new(owner: P, value: u32) -> SequencePropertyBuilder<P> {
38
        SequencePropertyBuilder {
38
            owner,
38
            inner: SequenceProperty {
38
                value,
38
                params: Vec::new(),
38
            },
38
        }
38
    }
    impl_finish_component_property_build!(ComponentProperty::Sequence);
}
impl_other_component_params_builder!(SequencePropertyBuilder<P>);
#[derive(Debug, PartialEq)]
pub struct RequestStatusProperty {
    pub(crate) value: RequestStatusPropertyValue,
    pub(crate) params: Vec<Param>,
}
#[derive(Debug, PartialEq)]
pub struct RequestStatusPropertyValue {
    pub(crate) status_code: Vec<u32>,
    pub(crate) description: String,
    pub(crate) exception_data: Option<String>,
}
impl_property_access!(RequestStatusProperty, RequestStatusPropertyValue);
pub struct RequestStatusPropertyBuilder<P: AddComponentProperty> {
    owner: P,
    inner: RequestStatusProperty,
}
impl<P> RequestStatusPropertyBuilder<P>
where
    P: AddComponentProperty,
{
50
    pub(crate) fn new(
50
        owner: P,
50
        status_code: Vec<u32>,
50
        description: String,
50
        exception_data: Option<String>,
50
    ) -> RequestStatusPropertyBuilder<P> {
50
        RequestStatusPropertyBuilder {
50
            owner,
50
            inner: RequestStatusProperty {
50
                value: RequestStatusPropertyValue {
50
                    status_code,
50
                    description,
50
                    exception_data,
50
                },
50
                params: Vec::new(),
50
            },
50
        }
50
    }
    language_param!();
    impl_finish_component_property_build!(ComponentProperty::RequestStatus);
}
impl_other_component_params_builder!(RequestStatusPropertyBuilder<P>);
#[derive(Debug, PartialEq)]
pub struct SummaryProperty {
    pub(crate) value: String,
    pub(crate) params: Vec<Param>,
}
impl_property_access!(SummaryProperty, String);
pub struct SummaryPropertyBuilder<P: AddComponentProperty> {
    owner: P,
    inner: SummaryProperty,
}
impl<P> SummaryPropertyBuilder<P>
where
    P: AddComponentProperty,
{
18
    pub(crate) fn new(owner: P, value: String) -> SummaryPropertyBuilder<P> {
18
        SummaryPropertyBuilder {
18
            owner,
18
            inner: SummaryProperty {
18
                value,
18
                params: Vec::new(),
18
            },
18
        }
18
    }
    altrep_param!();
    language_param!();
    impl_finish_component_property_build!(ComponentProperty::Summary);
}
impl_other_component_params_builder!(SummaryPropertyBuilder<P>);
#[derive(Debug, PartialEq)]
pub struct TimeTransparencyProperty {
    pub(crate) value: TimeTransparency,
    pub(crate) params: Vec<Param>,
}
impl_property_access!(TimeTransparencyProperty, TimeTransparency);
pub struct TimeTransparencyPropertyBuilder<P: AddComponentProperty> {
    owner: P,
    inner: TimeTransparencyProperty,
}
impl<P> TimeTransparencyPropertyBuilder<P>
where
    P: AddComponentProperty,
{
14
    pub(crate) fn new(owner: P, value: TimeTransparency) -> TimeTransparencyPropertyBuilder<P> {
14
        TimeTransparencyPropertyBuilder {
14
            owner,
14
            inner: TimeTransparencyProperty {
14
                value,
14
                params: Vec::new(),
14
            },
14
        }
14
    }
    impl_finish_component_property_build!(ComponentProperty::TimeTransparency);
}
impl_other_component_params_builder!(TimeTransparencyPropertyBuilder<P>);
#[derive(Debug, PartialEq)]
pub struct UrlProperty {
    // TODO should be a URI
    pub(crate) value: String,
    pub(crate) params: Vec<Param>,
}
impl_property_access!(UrlProperty, String);
pub struct UrlPropertyBuilder<P: AddComponentProperty> {
    owner: P,
    inner: UrlProperty,
}
impl<P> UrlPropertyBuilder<P>
where
    P: AddComponentProperty,
{
50
    pub(crate) fn new(owner: P, value: String) -> UrlPropertyBuilder<P> {
50
        UrlPropertyBuilder {
50
            owner,
50
            inner: UrlProperty {
50
                value,
50
                params: Vec::new(),
50
            },
50
        }
50
    }
    impl_finish_component_property_build!(ComponentProperty::Url);
}
impl_other_component_params_builder!(UrlPropertyBuilder<P>);
#[derive(Debug, PartialEq)]
pub struct RecurrenceIdProperty {
    pub(crate) value: CalendarDateTime,
    pub(crate) params: Vec<Param>,
}
impl_property_access!(RecurrenceIdProperty, CalendarDateTime);
pub struct RecurrenceIdPropertyBuilder<P: AddComponentProperty> {
    owner: P,
    inner: RecurrenceIdProperty,
}
impl<P> RecurrenceIdPropertyBuilder<P>
where
    P: AddComponentProperty,
{
38
    pub(crate) fn new(
38
        owner: P,
38
        date: time::Date,
38
        time: Option<time::Time>,
38
    ) -> RecurrenceIdPropertyBuilder<P> {
38
        let mut params = Vec::new();
38

            
38
        // The default is DATE-TIME. If the time is None, then it is a DATE and although it's
38
        // optional, this will default to setting the value here.
38
        if time.is_none() {
2
            params.push(Param::ValueType(ValueTypeParam { value: Value::Date }))
36
        }
38
        RecurrenceIdPropertyBuilder {
38
            owner,
38
            inner: RecurrenceIdProperty {
38
                value: (date, time, false).into(),
38
                params,
38
            },
38
        }
38
    }
    tz_id_param!();
    add_is_utc!();
14
    pub fn add_range(mut self, range: Range) -> Self {
14
        self.inner.params.push(Param::Range(RangeParam { range }));
14
        self
14
    }
    impl_finish_component_property_build!(ComponentProperty::RecurrenceId);
}
impl_other_component_params_builder!(RecurrenceIdPropertyBuilder<P>);
#[derive(Debug, PartialEq)]
pub struct RecurrenceRuleProperty {
    pub(crate) value: RecurrenceRule,
    pub(crate) params: Vec<Param>,
}
impl_property_access!(RecurrenceRuleProperty, RecurrenceRule);
pub struct RecurrenceRulePropertyBuilder<P: AddComponentProperty> {
    owner: P,
    inner: RecurrenceRuleProperty,
}
impl<P> RecurrenceRulePropertyBuilder<P>
where
    P: AddComponentProperty,
{
62
    pub(crate) fn new(owner: P, rule: RecurrenceRule) -> RecurrenceRulePropertyBuilder<P> {
62
        RecurrenceRulePropertyBuilder {
62
            owner,
62
            inner: RecurrenceRuleProperty {
62
                value: rule,
62
                params: Vec::new(),
62
            },
62
        }
62
    }
    impl_finish_component_property_build!(ComponentProperty::RecurrenceRule);
}
impl_other_component_params_builder!(RecurrenceRulePropertyBuilder<P>);
#[derive(Debug, Clone, PartialEq)]
pub struct DateTimeEndProperty {
    pub(crate) value: CalendarDateTime,
    pub(crate) params: Vec<Param>,
}
impl_property_access!(DateTimeEndProperty, CalendarDateTime);
pub struct DateTimeEndPropertyBuilder<P: AddComponentProperty> {
    owner: P,
    inner: DateTimeEndProperty,
}
impl<P> DateTimeEndPropertyBuilder<P>
where
    P: AddComponentProperty,
{
26
    pub(crate) fn new(
26
        owner: P,
26
        date: time::Date,
26
        time: Option<time::Time>,
26
    ) -> DateTimeEndPropertyBuilder<P> {
26
        let mut params = Vec::new();
26

            
26
        // The default is DATE-TIME. If the time is None, then it is a DATE and although it's
26
        // optional, this will default to setting the value here.
26
        if time.is_none() {
            params.push(Param::ValueType(ValueTypeParam { value: Value::Date }))
26
        }
26
        DateTimeEndPropertyBuilder {
26
            owner,
26
            inner: DateTimeEndProperty {
26
                value: (date, time, false).into(),
26
                params,
26
            },
26
        }
26
    }
    add_is_utc!();
    tz_id_param!();
    impl_finish_component_property_build!(ComponentProperty::DateTimeEnd);
}
impl_other_component_params_builder!(DateTimeEndPropertyBuilder<P>);
#[derive(Debug, PartialEq)]
pub struct DurationProperty {
    pub(crate) value: Duration,
    pub(crate) params: Vec<Param>,
}
impl_property_access!(DurationProperty, Duration);
pub struct DurationPropertyBuilder<P: AddComponentProperty> {
    owner: P,
    inner: DurationProperty,
}
impl<P> DurationPropertyBuilder<P>
where
    P: AddComponentProperty,
{
30
    pub(crate) fn new(owner: P, duration: Duration) -> DurationPropertyBuilder<P> {
30
        DurationPropertyBuilder {
30
            owner,
30
            inner: DurationProperty {
30
                value: duration,
30
                params: Vec::new(),
30
            },
30
        }
30
    }
    impl_finish_component_property_build!(ComponentProperty::Duration);
}
impl_other_component_params_builder!(DurationPropertyBuilder<P>);
#[derive(Debug, PartialEq)]
pub struct AttachProperty {
    pub(crate) value: String,
    pub(crate) params: Vec<Param>,
}
impl_property_access!(AttachProperty, String);
pub struct AttachPropertyBuilder<P: AddComponentProperty> {
    owner: P,
    inner: AttachProperty,
}
impl<P> AttachPropertyBuilder<P>
where
    P: AddComponentProperty,
{
42
    pub(crate) fn new_with_uri(owner: P, uri: String) -> AttachPropertyBuilder<P> {
42
        AttachPropertyBuilder {
42
            owner,
42
            inner: AttachProperty {
42
                value: uri,
42
                params: Vec::new(),
42
            },
42
        }
42
    }
4
    pub(crate) fn new_with_binary(owner: P, binary: String) -> AttachPropertyBuilder<P> {
4
        AttachPropertyBuilder {
4
            owner,
4
            inner: AttachProperty {
4
                value: binary,
4
                params: vec![
4
                    Param::Encoding(EncodingParam {
4
                        encoding: Encoding::Base64,
4
                    }),
4
                    Param::ValueType(ValueTypeParam {
4
                        value: Value::Binary,
4
                    }),
4
                ],
4
            },
4
        }
4
    }
14
    pub fn add_fmt_type<U: ToString, V: ToString>(
14
        mut self,
14
        type_name: U,
14
        sub_type_name: V,
14
    ) -> Self {
14
        self.inner.params.push(Param::FormatType(FormatTypeParam {
14
            type_name: type_name.to_string(),
14
            sub_type_name: sub_type_name.to_string(),
14
        }));
14
        self
14
    }
    impl_finish_component_property_build!(ComponentProperty::Attach);
}
impl_other_component_params_builder!(AttachPropertyBuilder<P>);
#[derive(Debug, PartialEq)]
pub struct AttendeeProperty {
    pub(crate) value: String,
    pub(crate) params: Vec<Param>,
}
impl_property_access!(AttendeeProperty, String);
pub struct AttendeePropertyBuilder<P: AddComponentProperty, PS> {
    owner: P,
    inner: AttendeeProperty,
    _phantom: PhantomData<PS>,
}
impl<P, PS> AttendeePropertyBuilder<P, PS>
where
    P: AddComponentProperty,
    PS: Into<ParticipationStatusUnknown>,
{
54
    pub(crate) fn new(owner: P, value: String) -> AttendeePropertyBuilder<P, PS> {
54
        AttendeePropertyBuilder {
54
            owner,
54
            inner: AttendeeProperty {
54
                value,
54
                params: Vec::new(),
54
            },
54
            _phantom: PhantomData,
54
        }
54
    }
12
    pub fn add_calendar_user_type(mut self, cu_type: CalendarUserType) -> Self {
12
        self.inner
12
            .params
12
            .push(Param::CalendarUserType(CalendarUserTypeParam { cu_type }));
12
        self
12
    }
14
    pub fn add_members(mut self, members: Vec<&str>) -> Self {
14
        self.inner.params.push(Param::Members(MembersParam {
14
            members: members.into_iter().map(|m| m.to_string()).collect(),
14
        }));
14
        self
14
    }
12
    pub fn add_role(mut self, role: Role) -> Self {
12
        self.inner.params.push(Param::Role(RoleParam { role }));
12
        self
12
    }
14
    pub fn add_participation_status(mut self, status: PS) -> Self {
14
        self.inner
14
            .params
14
            .push(Param::ParticipationStatus(ParticipationStatusParam {
14
                status: status.into(),
14
            }));
14
        self
14
    }
12
    pub fn add_rsvp(mut self) -> Self {
12
        // Default is false, add to set true
12
        self.inner
12
            .params
12
            .push(Param::Rsvp(RsvpParam { rsvp: true }));
12
        self
12
    }
12
    pub fn add_delegated_to(mut self, delegates: Vec<&str>) -> Self {
12
        self.inner.params.push(Param::DelegatedTo(DelegatedToParam {
12
            delegates: delegates.into_iter().map(|d| d.to_string()).collect(),
12
        }));
12
        self
12
    }
12
    pub fn add_delegated_from(mut self, delegators: Vec<&str>) -> Self {
12
        self.inner
12
            .params
12
            .push(Param::DelegatedFrom(DelegatedFromParam {
12
                delegators: delegators.into_iter().map(|d| d.to_string()).collect(),
12
            }));
12
        self
12
    }
    sent_by_param!();
    common_name_param!();
    directory_entry_reference_param!();
    language_param!();
    impl_finish_component_property_build!(ComponentProperty::Attendee);
}
impl_other_component_params_builder!(AttendeePropertyBuilder<P, PS>);
#[derive(Debug, PartialEq)]
pub struct CategoriesProperty {
    pub(crate) value: Vec<String>,
    pub(crate) params: Vec<Param>,
}
impl_property_access!(CategoriesProperty, Vec<String>);
pub struct CategoriesPropertyBuilder<P: AddComponentProperty> {
    owner: P,
    inner: CategoriesProperty,
}
impl<P> CategoriesPropertyBuilder<P>
where
    P: AddComponentProperty,
{
38
    pub(crate) fn new(owner: P, value: Vec<String>) -> CategoriesPropertyBuilder<P> {
38
        CategoriesPropertyBuilder {
38
            owner,
38
            inner: CategoriesProperty {
38
                value,
38
                params: Vec::new(),
38
            },
38
        }
38
    }
    language_param!();
    impl_finish_component_property_build!(ComponentProperty::Categories);
}
impl_other_component_params_builder!(CategoriesPropertyBuilder<P>);
#[derive(Debug, PartialEq)]
pub struct CommentProperty {
    pub(crate) value: String,
    pub(crate) params: Vec<Param>,
}
impl_property_access!(CommentProperty, String);
pub struct CommentPropertyBuilder<P: AddComponentProperty> {
    owner: P,
    inner: CommentProperty,
}
impl<P> CommentPropertyBuilder<P>
where
    P: AddComponentProperty,
{
26
    pub(crate) fn new(owner: P, value: String) -> CommentPropertyBuilder<P> {
26
        CommentPropertyBuilder {
26
            owner,
26
            inner: CommentProperty {
26
                value,
26
                params: Vec::new(),
26
            },
26
        }
26
    }
    altrep_param!();
    language_param!();
    impl_finish_component_property_build!(ComponentProperty::Comment);
}
impl_other_component_params_builder!(CommentPropertyBuilder<P>);
#[derive(Debug, PartialEq)]
pub struct ContactProperty {
    pub(crate) value: String,
    pub(crate) params: Vec<Param>,
}
impl_property_access!(ContactProperty, String);
pub struct ContactPropertyBuilder<P: AddComponentProperty> {
    owner: P,
    inner: ContactProperty,
}
impl<P> ContactPropertyBuilder<P>
where
    P: AddComponentProperty,
{
18
    pub(crate) fn new(owner: P, value: String) -> ContactPropertyBuilder<P> {
18
        ContactPropertyBuilder {
18
            owner,
18
            inner: ContactProperty {
18
                value,
18
                params: Vec::new(),
18
            },
18
        }
18
    }
    altrep_param!();
    language_param!();
    impl_finish_component_property_build!(ComponentProperty::Contact);
}
impl_other_component_params_builder!(ContactPropertyBuilder<P>);
#[derive(Debug, PartialEq)]
pub struct ExceptionDateTimesProperty {
    pub(crate) value: Vec<CalendarDateTime>,
    pub(crate) params: Vec<Param>,
}
impl_property_access!(ExceptionDateTimesProperty, Vec<CalendarDateTime>);
pub struct ExceptionDateTimesPropertyBuilder<P: AddComponentProperty> {
    owner: P,
    inner: ExceptionDateTimesProperty,
}
impl<P> ExceptionDateTimesPropertyBuilder<P>
where
    P: AddComponentProperty,
{
38
    pub(crate) fn new(owner: P, date_times: Vec<CalendarDateTime>) -> Self {
38
        let mut params = Vec::new();
38
        if date_times.first().map(|dt| dt.is_date()).unwrap_or(false) {
2
            params.push(Param::ValueType(ValueTypeParam { value: Value::Date }));
38
        }
38
        ExceptionDateTimesPropertyBuilder {
38
            owner,
38
            inner: ExceptionDateTimesProperty {
38
                value: date_times,
38
                params,
38
            },
38
        }
38
    }
    tz_id_param!();
    impl_finish_component_property_build!(ComponentProperty::ExceptionDateTimes);
}
impl_other_component_params_builder!(ExceptionDateTimesPropertyBuilder<P>);
#[derive(Debug, PartialEq)]
pub struct StatusProperty {
    pub(crate) value: Status,
    pub(crate) params: Vec<Param>,
}
impl_property_access!(StatusProperty, Status);
pub struct StatusPropertyBuilder<P: AddComponentProperty> {
    owner: P,
    inner: StatusProperty,
}
impl<P> StatusPropertyBuilder<P>
where
    P: AddComponentProperty,
{
38
    pub(crate) fn new(owner: P, value: Status) -> StatusPropertyBuilder<P> {
38
        StatusPropertyBuilder {
38
            owner,
38
            inner: StatusProperty {
38
                value,
38
                params: Vec::new(),
38
            },
38
        }
38
    }
    impl_finish_component_property_build!(ComponentProperty::Status);
}
impl_other_component_params_builder!(StatusPropertyBuilder<P>);
#[derive(Debug, PartialEq)]
pub struct RelatedToProperty {
    pub(crate) value: String,
    pub(crate) params: Vec<Param>,
}
impl_property_access!(RelatedToProperty, String);
pub struct RelatedToPropertyBuilder<P: AddComponentProperty> {
    owner: P,
    inner: RelatedToProperty,
}
impl<P> RelatedToPropertyBuilder<P>
where
    P: AddComponentProperty,
{
38
    pub(crate) fn new(owner: P, value: String) -> RelatedToPropertyBuilder<P> {
38
        RelatedToPropertyBuilder {
38
            owner,
38
            inner: RelatedToProperty {
38
                value,
38
                params: Vec::new(),
38
            },
38
        }
38
    }
14
    pub fn add_relationship_type(mut self, relationship_type: RelationshipType) -> Self {
14
        self.inner
14
            .params
14
            .push(Param::RelationshipType(RelationshipTypeParam {
14
                relationship: relationship_type,
14
            }));
14
        self
14
    }
    impl_finish_component_property_build!(ComponentProperty::RelatedTo);
}
impl_other_component_params_builder!(RelatedToPropertyBuilder<P>);
#[derive(Debug, PartialEq)]
pub struct ResourcesProperty {
    pub(crate) value: Vec<String>,
    pub(crate) params: Vec<Param>,
}
impl_property_access!(ResourcesProperty, Vec<String>);
pub struct ResourcesPropertyBuilder<P: AddComponentProperty> {
    owner: P,
    inner: ResourcesProperty,
}
impl<P> ResourcesPropertyBuilder<P>
where
    P: AddComponentProperty,
{
26
    pub(crate) fn new(owner: P, value: Vec<String>) -> ResourcesPropertyBuilder<P> {
26
        ResourcesPropertyBuilder {
26
            owner,
26
            inner: ResourcesProperty {
26
                value,
26
                params: Vec::new(),
26
            },
26
        }
26
    }
    altrep_param!();
    language_param!();
    impl_finish_component_property_build!(ComponentProperty::Resources);
}
impl_other_component_params_builder!(ResourcesPropertyBuilder<P>);
#[derive(Clone, Debug, PartialEq)]
pub struct Period {
    pub start: (time::Date, time::Time, bool),
    pub end: PeriodEnd,
}
impl Period {
12
    pub fn new_explicit(
12
        start_date: time::Date,
12
        start_time: time::Time,
12
        end_date: time::Date,
12
        end_time: time::Time,
12
        is_utc: bool,
12
    ) -> Self {
12
        Period {
12
            start: (start_date, start_time, is_utc),
12
            end: PeriodEnd::DateTime((end_date, end_time, is_utc)),
12
        }
12
    }
14
    pub fn new_start(
14
        start_date: time::Date,
14
        start_time: time::Time,
14
        is_utc: bool,
14
        duration: Duration,
14
    ) -> Self {
14
        Period {
14
            start: (start_date, start_time, is_utc),
14
            end: PeriodEnd::Duration(duration),
14
        }
14
    }
12
    pub fn expand(&self) -> anyhow::Result<Option<(CalendarDateTime, CalendarDateTime)>> {
12
        if self.start.2 {
            Ok(Some((
12
                self.start.into(),
12
                match &self.end {
6
                    PeriodEnd::DateTime(end) => (*end).into(),
6
                    PeriodEnd::Duration(duration) => {
6
                        let cdt: CalendarDateTime = self.start.into();
6
                        cdt.add(duration)?
                    }
                },
            )))
        } else {
            Ok(None)
        }
12
    }
}
#[derive(Clone, Debug, PartialEq)]
pub enum PeriodEnd {
    DateTime((time::Date, time::Time, bool)),
    Duration(Duration),
}
#[derive(Debug, PartialEq)]
pub struct RecurrenceDateTimesProperty {
    pub(crate) value: RecurrenceDateTimesPropertyValue,
    pub(crate) params: Vec<Param>,
}
#[derive(Debug, PartialEq)]
pub enum RecurrenceDateTimesPropertyValue {
    DateTimes(Vec<CalendarDateTime>),
    Periods(Vec<Period>),
}
impl_property_access!(
    RecurrenceDateTimesProperty,
    RecurrenceDateTimesPropertyValue
);
pub struct RecurrenceDateTimesPropertyBuilder<P: AddComponentProperty> {
    owner: P,
    inner: RecurrenceDateTimesProperty,
}
impl<P> RecurrenceDateTimesPropertyBuilder<P>
where
    P: AddComponentProperty,
{
60
    pub fn new_date_times(owner: P, date_times: Vec<CalendarDateTime>) -> Self {
60
        let mut params = Vec::new();
60
        if date_times.first().map(|dt| dt.is_date()).unwrap_or(false) {
            params.push(Param::ValueType(ValueTypeParam { value: Value::Date }));
60
        }
60
        RecurrenceDateTimesPropertyBuilder {
60
            owner,
60
            inner: RecurrenceDateTimesProperty {
60
                value: RecurrenceDateTimesPropertyValue::DateTimes(date_times),
60
                params,
60
            },
60
        }
60
    }
2
    pub fn new_periods(owner: P, periods: Vec<Period>) -> Self {
2
        RecurrenceDateTimesPropertyBuilder {
2
            owner,
2
            inner: RecurrenceDateTimesProperty {
2
                value: RecurrenceDateTimesPropertyValue::Periods(periods),
2
                params: vec![Param::ValueType(ValueTypeParam {
2
                    value: Value::Period,
2
                })],
2
            },
2
        }
2
    }
    tz_id_param!();
    impl_finish_component_property_build!(ComponentProperty::RecurrenceDateTimes);
}
impl_other_component_params_builder!(RecurrenceDateTimesPropertyBuilder<P>);
#[derive(Debug, PartialEq)]
pub struct DateTimeCompletedProperty {
    pub(crate) value: CalendarDateTime,
    pub(crate) params: Vec<Param>,
}
impl_property_access!(DateTimeCompletedProperty, CalendarDateTime);
pub struct CompletedPropertyBuilder<P: AddComponentProperty> {
    owner: P,
    inner: DateTimeCompletedProperty,
}
impl<P> CompletedPropertyBuilder<P>
where
    P: AddComponentProperty,
{
12
    pub(crate) fn new(owner: P, date: time::Date, time: time::Time) -> CompletedPropertyBuilder<P> {
12
        CompletedPropertyBuilder {
12
            owner,
12
            inner: DateTimeCompletedProperty {
12
                value: (date, time, false).into(),
12
                params: Vec::new(),
12
            },
12
        }
12
    }
    add_is_utc!();
    impl_finish_component_property_build!(ComponentProperty::DateTimeCompleted);
}
impl_other_component_params_builder!(CompletedPropertyBuilder<P>);
#[derive(Debug, PartialEq)]
pub struct PercentCompleteProperty {
    pub(crate) value: u8,
    pub(crate) params: Vec<Param>,
}
impl_property_access!(PercentCompleteProperty, u8);
pub struct PercentCompletePropertyBuilder<P: AddComponentProperty> {
    owner: P,
    inner: PercentCompleteProperty,
}
impl<P> PercentCompletePropertyBuilder<P>
where
    P: AddComponentProperty,
{
12
    pub(crate) fn new(owner: P, value: u8) -> PercentCompletePropertyBuilder<P> {
12
        PercentCompletePropertyBuilder {
12
            owner,
12
            inner: PercentCompleteProperty {
12
                value,
12
                params: Vec::new(),
12
            },
12
        }
12
    }
    impl_finish_component_property_build!(ComponentProperty::PercentComplete);
}
impl_other_component_params_builder!(PercentCompletePropertyBuilder<P>);
#[derive(Debug, Clone, PartialEq)]
pub struct DateTimeDueProperty {
    pub(crate) value: CalendarDateTime,
    pub(crate) params: Vec<Param>,
}
impl_property_access!(DateTimeDueProperty, CalendarDateTime);
pub struct DateTimeDuePropertyBuilder<P: AddComponentProperty> {
    owner: P,
    inner: DateTimeDueProperty,
}
impl<P> DateTimeDuePropertyBuilder<P>
where
    P: AddComponentProperty,
{
    pub(crate) fn new(
        owner: P,
        date: time::Date,
        time: Option<time::Time>,
    ) -> DateTimeDuePropertyBuilder<P> {
        let mut params = Vec::new();
        // The default is DATE-TIME. If the time is None, then it is a DATE and although it's
        // optional, this will default to setting the value here.
        if time.is_none() {
            params.push(Param::ValueType(ValueTypeParam { value: Value::Date }))
        }
        DateTimeDuePropertyBuilder {
            owner,
            inner: DateTimeDueProperty {
                value: (date, time, false).into(),
                params,
            },
        }
    }
    tz_id_param!();
    add_is_utc!();
    impl_finish_component_property_build!(ComponentProperty::DateTimeDue);
}
impl_other_component_params_builder!(DateTimeDuePropertyBuilder<P>);
#[derive(Debug, PartialEq)]
pub struct FreeBusyTimeProperty {
    pub(crate) value: Vec<Period>,
    pub(crate) params: Vec<Param>,
}
impl_property_access!(FreeBusyTimeProperty, Vec<Period>);
pub struct FreeBusyTimePropertyBuilder<P: AddComponentProperty> {
    owner: P,
    inner: FreeBusyTimeProperty,
}
impl<P> FreeBusyTimePropertyBuilder<P>
where
    P: AddComponentProperty,
{
12
    pub(crate) fn new(
12
        owner: P,
12
        free_busy_time_type: FreeBusyTimeType,
12
        value: Vec<Period>,
12
    ) -> FreeBusyTimePropertyBuilder<P> {
12
        FreeBusyTimePropertyBuilder {
12
            owner,
12
            inner: FreeBusyTimeProperty {
12
                value,
12
                params: vec![Param::FreeBusyTimeType(FreeBusyTimeTypeParam {
12
                    fb_type: free_busy_time_type,
12
                })],
12
            },
12
        }
12
    }
    impl_finish_component_property_build!(ComponentProperty::FreeBusyTime);
}
impl_other_component_params_builder!(FreeBusyTimePropertyBuilder<P>);
#[derive(Debug, PartialEq)]
pub struct TimeZoneIdProperty {
    pub(crate) value: TimeZoneIdPropertyValue,
    pub(crate) params: Vec<Param>,
}
#[derive(Debug, Clone, PartialEq)]
pub struct TimeZoneIdPropertyValue {
    pub id: String,
    pub unique_registry_id: bool,
}
impl_property_access!(TimeZoneIdProperty, TimeZoneIdPropertyValue);
pub struct TimeZoneIdPropertyBuilder<P: AddComponentProperty> {
    owner: P,
    inner: TimeZoneIdProperty,
}
impl<P> TimeZoneIdPropertyBuilder<P>
where
    P: AddComponentProperty,
{
12
    pub(crate) fn new(
12
        owner: P,
12
        value: String,
12
        unique_registry_id: bool,
12
    ) -> TimeZoneIdPropertyBuilder<P> {
12
        TimeZoneIdPropertyBuilder {
12
            owner,
12
            inner: TimeZoneIdProperty {
12
                value: TimeZoneIdPropertyValue {
12
                    id: value,
12
                    unique_registry_id,
12
                },
12
                params: Vec::new(),
12
            },
12
        }
12
    }
    impl_finish_component_property_build!(ComponentProperty::TimeZoneId);
}
impl_other_component_params_builder!(TimeZoneIdPropertyBuilder<P>);
#[derive(Debug, PartialEq)]
pub struct TimeZoneUrlProperty {
    pub(crate) value: String,
    pub(crate) params: Vec<Param>,
}
impl_property_access!(TimeZoneUrlProperty, String);
pub struct TimeZoneUrlPropertyBuilder<P: AddComponentProperty> {
    owner: P,
    inner: TimeZoneUrlProperty,
}
impl<P> TimeZoneUrlPropertyBuilder<P>
where
    P: AddComponentProperty,
{
12
    pub(crate) fn new(owner: P, value: String) -> TimeZoneUrlPropertyBuilder<P> {
12
        TimeZoneUrlPropertyBuilder {
12
            owner,
12
            inner: TimeZoneUrlProperty {
12
                value,
12
                params: Vec::new(),
12
            },
12
        }
12
    }
    impl_finish_component_property_build!(ComponentProperty::TimeZoneUrl);
}
impl_other_component_params_builder!(TimeZoneUrlPropertyBuilder<P>);
#[derive(Debug, PartialEq)]
pub struct TimeZoneOffset {
    pub(crate) sign: i8,
    pub(crate) hours: u8,
    pub(crate) minutes: u8,
    pub(crate) seconds: Option<u8>,
}
impl TimeZoneOffset {
48
    pub fn new(sign: i8, hours: u8, minutes: u8, seconds: Option<u8>) -> Self {
48
        TimeZoneOffset {
48
            sign,
48
            hours,
48
            minutes,
48
            seconds,
48
        }
48
    }
}
#[derive(Debug, PartialEq)]
pub struct TimeZoneOffsetToProperty {
    pub(crate) value: TimeZoneOffset,
    pub(crate) params: Vec<Param>,
}
impl_property_access!(TimeZoneOffsetToProperty, TimeZoneOffset);
pub struct TimeZoneOffsetToPropertyBuilder<P: AddComponentProperty> {
    owner: P,
    inner: TimeZoneOffsetToProperty,
}
impl<P> TimeZoneOffsetToPropertyBuilder<P>
where
    P: AddComponentProperty,
{
24
    pub(crate) fn new(owner: P, offset: TimeZoneOffset) -> TimeZoneOffsetToPropertyBuilder<P> {
24
        TimeZoneOffsetToPropertyBuilder {
24
            owner,
24
            inner: TimeZoneOffsetToProperty {
24
                value: offset,
24
                params: Vec::new(),
24
            },
24
        }
24
    }
    impl_finish_component_property_build!(ComponentProperty::TimeZoneOffsetTo);
}
impl_other_component_params_builder!(TimeZoneOffsetToPropertyBuilder<P>);
#[derive(Debug, PartialEq)]
pub struct TimeZoneOffsetFromProperty {
    pub(crate) value: TimeZoneOffset,
    pub(crate) params: Vec<Param>,
}
impl_property_access!(TimeZoneOffsetFromProperty, TimeZoneOffset);
pub struct TimeZoneOffsetFromPropertyBuilder<P: AddComponentProperty> {
    owner: P,
    inner: TimeZoneOffsetFromProperty,
}
impl<P> TimeZoneOffsetFromPropertyBuilder<P>
where
    P: AddComponentProperty,
{
24
    pub(crate) fn new(owner: P, offset: TimeZoneOffset) -> TimeZoneOffsetFromPropertyBuilder<P> {
24
        TimeZoneOffsetFromPropertyBuilder {
24
            owner,
24
            inner: TimeZoneOffsetFromProperty {
24
                value: offset,
24
                params: Vec::new(),
24
            },
24
        }
24
    }
    impl_finish_component_property_build!(ComponentProperty::TimeZoneOffsetFrom);
}
impl_other_component_params_builder!(TimeZoneOffsetFromPropertyBuilder<P>);
#[derive(Debug, PartialEq)]
pub struct TimeZoneNameProperty {
    pub(crate) value: String,
    pub(crate) params: Vec<Param>,
}
impl_property_access!(TimeZoneNameProperty, String);
pub struct TimeZoneNamePropertyBuilder<P: AddComponentProperty> {
    owner: P,
    inner: TimeZoneNameProperty,
}
impl<P> TimeZoneNamePropertyBuilder<P>
where
    P: AddComponentProperty,
{
24
    pub(crate) fn new(owner: P, value: String) -> TimeZoneNamePropertyBuilder<P> {
24
        TimeZoneNamePropertyBuilder {
24
            owner,
24
            inner: TimeZoneNameProperty {
24
                value,
24
                params: Vec::new(),
24
            },
24
        }
24
    }
    language_param!();
    impl_finish_component_property_build!(ComponentProperty::TimeZoneName);
}
impl_other_component_params_builder!(TimeZoneNamePropertyBuilder<P>);
#[derive(Debug, Clone, PartialEq)]
pub enum Action {
    Audio,
    Display,
    Email,
    XName(String),
    IanaToken(String),
}
#[derive(Debug, PartialEq)]
pub struct ActionProperty {
    pub(crate) value: Action,
    pub(crate) params: Vec<Param>,
}
impl_property_access!(ActionProperty, Action);
pub struct ActionPropertyBuilder<P: AddComponentProperty> {
    owner: P,
    inner: ActionProperty,
}
impl<P> ActionPropertyBuilder<P>
where
    P: AddComponentProperty,
{
16
    pub(crate) fn new(owner: P, value: Action) -> ActionPropertyBuilder<P> {
16
        ActionPropertyBuilder {
16
            owner,
16
            inner: ActionProperty {
16
                value,
16
                params: Vec::new(),
16
            },
16
        }
16
    }
    impl_finish_component_property_build!(ComponentProperty::Action);
}
impl_other_component_params_builder!(ActionPropertyBuilder<P>);
#[derive(Debug)]
pub struct RelativeTriggerProperty {
    pub(crate) value: Duration,
    pub(crate) params: Vec<Param>,
}
pub struct RelativeTriggerPropertyBuilder<P: AddComponentProperty> {
    owner: P,
    inner: RelativeTriggerProperty,
}
impl<P> RelativeTriggerPropertyBuilder<P>
where
    P: AddComponentProperty,
{
8
    pub(crate) fn new(owner: P, value: Duration) -> RelativeTriggerPropertyBuilder<P> {
8
        RelativeTriggerPropertyBuilder {
8
            owner,
8
            inner: RelativeTriggerProperty {
8
                value,
8
                params: Vec::new(),
8
            },
8
        }
8
    }
4
    pub fn add_trigger_relationship(mut self, trigger_relationship: TriggerRelationship) -> Self {
4
        self.inner
4
            .params
4
            .push(Param::TriggerRelationship(TriggerRelationshipParam {
4
                trigger_relationship,
4
            }));
4
        self
4
    }
8
    pub fn finish_property(mut self) -> P {
8
        self.owner
8
            .add_property(ComponentProperty::Trigger(TriggerProperty {
8
                value: TriggerValue::Relative(self.inner.value),
8
                params: self.inner.params,
8
            }));
8
        self.owner
8
    }
}
impl_other_component_params_builder!(RelativeTriggerPropertyBuilder<P>);
#[derive(Debug)]
pub(crate) struct AbsoluteTriggerProperty {
    pub(crate) value: CalendarDateTime,
    pub(crate) params: Vec<Param>,
}
pub struct AbsoluteTriggerPropertyBuilder<P: AddComponentProperty> {
    owner: P,
    inner: AbsoluteTriggerProperty,
}
impl<P> AbsoluteTriggerPropertyBuilder<P>
where
    P: AddComponentProperty,
{
8
    pub(crate) fn new(
8
        owner: P,
8
        date: time::Date,
8
        time: time::Time,
8
    ) -> AbsoluteTriggerPropertyBuilder<P> {
8
        AbsoluteTriggerPropertyBuilder {
8
            owner,
8
            inner: AbsoluteTriggerProperty {
8
                value: (date, time, false).into(),
8
                params: vec![Param::ValueType(ValueTypeParam {
8
                    value: Value::DateTime,
8
                })],
8
            },
8
        }
8
    }
    add_is_utc!();
8
    pub fn finish_property(mut self) -> P {
8
        self.owner
8
            .add_property(ComponentProperty::Trigger(TriggerProperty {
8
                value: TriggerValue::Absolute(self.inner.value),
8
                params: self.inner.params,
8
            }));
8
        self.owner
8
    }
}
impl_other_component_params_builder!(AbsoluteTriggerPropertyBuilder<P>);
#[derive(Debug, PartialEq)]
pub struct RepeatProperty {
    pub(crate) value: u32,
    pub(crate) params: Vec<Param>,
}
impl_property_access!(RepeatProperty, u32);
pub struct RepeatPropertyBuilder<P: AddComponentProperty> {
    owner: P,
    inner: RepeatProperty,
}
impl<P> RepeatPropertyBuilder<P>
where
    P: AddComponentProperty,
{
16
    pub(crate) fn new(owner: P, value: u32) -> RepeatPropertyBuilder<P> {
16
        RepeatPropertyBuilder {
16
            owner,
16
            inner: RepeatProperty {
16
                value,
16
                params: Vec::new(),
16
            },
16
        }
16
    }
    impl_finish_component_property_build!(ComponentProperty::Repeat);
}
impl_other_component_params_builder!(RepeatPropertyBuilder<P>);