Skip to main content

ical/tree/prop/
completed.rs

1//! # COMPLETED lens
2//!
3//! The `COMPLETED` property lens.
4
5use crate::{
6    prop::IcalPropKind,
7    tree::{
8        line::IcalLine,
9        prop::{cardinality::IcalPropCardinality, lens::IcalPropLens, spec::IcalPropSpec},
10        value::cursor::IcalValueCursor,
11    },
12    value::IcalValueKind,
13    value::datetime::IcalDateTime,
14    version::IcalVersion,
15};
16
17/// The `COMPLETED` property lens.
18#[allow(non_camel_case_types)]
19pub struct COMPLETED;
20
21impl IcalPropLens for COMPLETED {
22    type Target<'v> = IcalDateTime<'v>;
23
24    type Cursor<'c, 'a>
25        = IcalValueCursor<'c, 'a>
26    where
27        'a: 'c;
28
29    fn cursor<'c, 'a>(line: &'c mut IcalLine<'a>) -> IcalValueCursor<'c, 'a> {
30        IcalValueCursor { line }
31    }
32}
33
34impl IcalPropSpec for COMPLETED {
35    const KIND: IcalPropKind = IcalPropKind::Completed;
36
37    fn cardinality(_version: IcalVersion) -> IcalPropCardinality {
38        IcalPropCardinality::AtMostOne
39    }
40
41    fn allowed_values(_version: IcalVersion) -> &'static [IcalValueKind] {
42        &[IcalValueKind::DateTime]
43    }
44}