1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
use super::properties::*;
use crate::{validator::validate_properties, DateFilter, RRuleError, RRuleIter};
use std::str::FromStr;
#[derive(Clone, Debug)]
pub struct RRule {
properties: RRuleProperties,
}
impl RRule {
pub fn new(properties: RRuleProperties) -> Result<Self, RRuleError> {
let datetime = properties.dt_start;
let properties = crate::parser::finalize_parsed_properties(properties, &datetime)?;
let validated_properties = validate_properties(properties)?;
Ok(Self {
properties: validated_properties,
})
}
pub fn get_properties(&self) -> &RRuleProperties {
&self.properties
}
}
impl FromStr for RRule {
type Err = RRuleError;
fn from_str(s: &str) -> Result<Self, Self::Err> {
let properties = crate::parser::parse_rrule_string_to_properties(s)?;
RRule::new(properties)
}
}
impl<'a> DateFilter<'a, RRuleIter<'a>> for RRule {}