vcard-rs 0.1.0

vCard parser, validator, editor and builder library for Rust
Documentation
//! # EMAIL lens
//!
//! The `EMAIL` property lens: an email address for the contact, decoded as a
//! text value.
//!
//! See RFC 6350 6.4.2.

use crate::{
    param::VcardParamKind,
    prop::VcardPropKind,
    tree::{
        line::VcardLine,
        prop::{VcardPropLens, VcardPropSpec},
        value::VcardValueCursor,
    },
    value::text::VcardText,
    version::VcardVersion,
};

/// The `EMAIL` property lens.
pub struct EMAIL;

impl VcardPropLens for EMAIL {
    type Target<'v> = VcardText<'v>;

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

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

impl VcardPropSpec for EMAIL {
    const KIND: VcardPropKind = VcardPropKind::Email;

    fn allowed_params(_version: VcardVersion) -> &'static [VcardParamKind] {
        &[
            VcardParamKind::Type,
            VcardParamKind::Pid,
            VcardParamKind::Pref,
            VcardParamKind::AltId,
            VcardParamKind::Value,
        ]
    }
}