ical-rs 0.1.0

iCalendar parser, validator, editor and builder library for Rust
Documentation
//! # LAST_MODIFIED lens
//!
//! The `LAST_MODIFIED` property lens.

use crate::{
    prop::IcalPropKind,
    tree::{
        line::IcalLine,
        prop::{IcalPropCardinality, IcalPropLens, IcalPropSpec},
        value::IcalValueCursor,
    },
    value::IcalValueKind,
    value::datetime::IcalDateTime,
    version::IcalVersion,
};

/// The `LAST_MODIFIED` property lens.
#[allow(non_camel_case_types)]
pub struct LAST_MODIFIED;

impl IcalPropLens for LAST_MODIFIED {
    type Target<'v> = IcalDateTime<'v>;

    type Cursor<'c, 'a>
        = IcalValueCursor<'c, 'a>
    where
        'a: 'c;

    fn cursor<'c, 'a>(line: &'c mut IcalLine<'a>) -> IcalValueCursor<'c, 'a> {
        IcalValueCursor { line }
    }
}

impl IcalPropSpec for LAST_MODIFIED {
    const KIND: IcalPropKind = IcalPropKind::LastModified;

    fn cardinality(_version: IcalVersion) -> IcalPropCardinality {
        IcalPropCardinality::AtMostOne
    }

    fn allowed_values(_version: IcalVersion) -> &'static [IcalValueKind] {
        &[IcalValueKind::DateTime]
    }
}