Skip to main content

Module builder

Module builder 

Source
Expand description

§Property builder

Strict, version-aware construction of a single property.

IcalPropBuilder is the write-side counterpart of the lenses: keyed by the same zero-sized property markers, it carries the calendar version, accumulates parameters, and emits an open IcalProp.

Its name is pinned by the marker’s IcalPropSpec, and build runs the shared per-property check (validate_prop), so a known property must be defined in the calendar’s version (extensions pass).

To emit something the spec forbids, construct the open IcalProp by hand. The version is a value the builder carries, never a type parameter.

§Example

use ical::builder::IcalPropBuilder;
use ical::prop::summary::SUMMARY;
use ical::param::IcalParam;
use ical::value::IcalValue;
use ical::value::text::IcalText;
use ical::version::IcalVersion;
use std::borrow::Cow;

let prop = IcalPropBuilder::<SUMMARY>::new(IcalVersion::V2_0)
    .param(IcalParam::Language(Cow::Borrowed("en")))
    .build(IcalValue::Text(IcalText(Cow::Borrowed("Lunch"))))
    .expect("SUMMARY accepts text with a LANGUAGE parameter");

assert_eq!(&*prop.name, "SUMMARY");

Structs§

IcalPropBuilder
A version-aware builder for one property, keyed by its property marker.