Skip to main content

ical/tree/value/
recur.rs

1//! # RECUR value codec (RFC 5545 3.3.10)
2//!
3//! [`Codec`] for a recurrence rule. A RECUR value uses `;` to separate its
4//! rule parts (`FREQ=DAILY;COUNT=10`), which the generic node reads as separate
5//! components; the whole value is kept, separators and all, and written back
6//! verbatim (unescaped, since RECUR is not TEXT) on encode.
7
8use crate::{
9    tree::{
10        codec::{Codec, mode::Escaper},
11        value::node::IcalValueNode,
12    },
13    value::recur::IcalRecur,
14};
15
16impl<'v> Codec<'v> for IcalRecur<'v> {
17    fn decode(node: &'v IcalValueNode<'_>) -> Self {
18        IcalRecur(node.decode())
19    }
20
21    fn encode(&self, escaper: Escaper) -> IcalValueNode<'static> {
22        let mut node = IcalValueNode::parse(self.0.as_bytes()).into_static();
23        node.escaper = escaper;
24        node
25    }
26}