| 1 | //! Module for parsing text inputs to a [`Grammar`] which can further be used |
| 2 | //! to construct an [`crate::RRuleSet`]. |
| 3 | mod content_linerust-analyzer cargo rrule 0.14.0 parser/content_line/; |
| 4 | mod datetimerust-analyzer cargo rrule 0.14.0 parser/datetime/; |
| 5 | mod errorrust-analyzer cargo rrule 0.14.0 parser/error/; |
| 6 | mod regexrust-analyzer cargo rrule 0.14.0 parser/regex/; |
| 7 | mod utilsrust-analyzer cargo rrule 0.14.0 parser/utils/; |
| 8 | |
| 9 | use stdrust-analyzer cargo std https://github.com/rust-lang/rust/library/std crate/::strrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc str/::FromStrrust-analyzer cargo core https://github.com/rust-lang/rust/library/core str/traits/FromStr#; |
| 10 | |
| 11 | pub(craterust-analyzer cargo rrule 0.14.0 crate/) use content_linerust-analyzer cargo rrule 0.14.0 parser/content_line/::{ContentLinerust-analyzer cargo rrule 0.14.0 parser/content_line/ContentLine#, ContentLineCapturesrust-analyzer cargo rrule 0.14.0 parser/content_line/content_line_parts/ContentLineCaptures#}; |
| 12 | pub(craterust-analyzer cargo rrule 0.14.0 crate/) use datetimerust-analyzer cargo rrule 0.14.0 parser/datetime/::str_to_weekdayrust-analyzer cargo rrule 0.14.0 parser/datetime/str_to_weekday().; |
| 13 | pub use errorrust-analyzer cargo rrule 0.14.0 parser/error/::ParseErrorrust-analyzer cargo rrule 0.14.0 parser/error/ParseError#; |
| 14 | |
| 15 | use craterust-analyzer cargo rrule 0.14.0 crate/::RRulerust-analyzer cargo rrule 0.14.0 core/rrule/RRule#; |
| 16 | |
| 17 | use selfrust-analyzer cargo rrule 0.14.0 parser/::content_linerust-analyzer cargo rrule 0.14.0 parser/content_line/::{PropertyNamerust-analyzer cargo rrule 0.14.0 parser/content_line/PropertyName#, StartDateContentLinerust-analyzer cargo rrule 0.14.0 parser/content_line/start_date_content_line/StartDateContentLine#}; |
| 18 | |
| 19 | /// Grammar represents a well-formatted rrule input. |
| 20 | #[deriverust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/derive:(Debugrust-analyzer cargo core https://github.com/rust-lang/rust/library/core fmt/macros/Debug:, PartialEqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/PartialEq:)] |
| 21 | pub(craterust-analyzer cargo rrule 0.14.0 crate/) struct Grammarrust-analyzer cargo rrule 0.14.0 parser/Grammar# { |
| 22 | pub startrust-analyzer cargo rrule 0.14.0 parser/Grammar#start.: Optionrust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#<StartDateContentLinerust-analyzer cargo rrule 0.14.0 parser/content_line/start_date_content_line/StartDateContentLine#>, |
| 23 | pub content_linesrust-analyzer cargo rrule 0.14.0 parser/Grammar#content_lines.: Vecrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/Vec#<ContentLinerust-analyzer cargo rrule 0.14.0 parser/content_line/ContentLine#>, |
| 24 | } |
| 25 | |
| 26 | impl FromStrrust-analyzer cargo core https://github.com/rust-lang/rust/library/core str/traits/FromStr# for Grammarrust-analyzer cargo rrule 0.14.0 parser/Grammar# { |
| 27 | type Errrust-analyzer cargo rrule 0.14.0 parser/impl#[Grammar][FromStr]Err# = ParseErrorrust-analyzer cargo rrule 0.14.0 parser/error/ParseError#; |
| 28 | |
| 29 | fn from_strrust-analyzer cargo rrule 0.14.0 parser/impl#[Grammar][FromStr]from_str().(s: &str) -> Resultrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#<Selfrust-analyzer cargo rrule 0.14.0 parser/impl#[Grammar][FromStr], Selfrust-analyzer cargo rrule 0.14.0 parser/impl#[Grammar][FromStr]::Errrust-analyzer cargo core https://github.com/rust-lang/rust/library/core str/traits/FromStr#Err#> { |
| 30 | let content_lines_parts = s |
| 31 | .linesrust-analyzer cargo core https://github.com/rust-lang/rust/library/core str/impl#[str]lines().() |
| 32 | .maprust-analyzer cargo core https://github.com/rust-lang/rust/library/core iter/traits/iterator/Iterator#map().(ContentLineCapturesrust-analyzer cargo rrule 0.14.0 parser/content_line/content_line_parts/ContentLineCaptures#::newrust-analyzer cargo rrule 0.14.0 parser/content_line/content_line_parts/impl#[`ContentLineCaptures<'a>`]new().) |
| 33 | .collectrust-analyzer cargo core https://github.com/rust-lang/rust/library/core iter/traits/iterator/Iterator#collect().::<Resultrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#<Vecrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/Vec#<_>, _>>()?rust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`][Try]branch().; |
| 34 | |
| 35 | let start = content_lines_parts |
| 36 | .iterrust-analyzer cargo core https://github.com/rust-lang/rust/library/core slice/impl#[`[T]`]iter().() |
| 37 | .findrust-analyzer cargo core https://github.com/rust-lang/rust/library/core slice/iter/impl#[`Iter<'a, T>`][Iterator]find().(|parts| matchesrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/matches!!(parts.property_namerust-analyzer cargo rrule 0.14.0 parser/content_line/content_line_parts/ContentLineCaptures#property_name., PropertyNamerust-analyzer cargo rrule 0.14.0 parser/content_line/PropertyName#::DtStartrust-analyzer cargo rrule 0.14.0 parser/content_line/PropertyName#DtStart#)) |
| 38 | .maprust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/impl#[`Option<T>`]map().(StartDateContentLinerust-analyzer cargo rrule 0.14.0 parser/content_line/start_date_content_line/StartDateContentLine#::try_fromrust-analyzer cargo rrule 0.14.0 parser/content_line/start_date_content_line/impl#[StartDateContentLine][`TryFrom<&ContentLineCaptures<'_>>`]try_from().) |
| 39 | .transposerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/impl#[`Option<Result<T, E>>`]transpose().()?rust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`][Try]branch().; |
| 40 | |
| 41 | let mut content_lines = vecrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc macros/vec!![]; |
| 42 | |
| 43 | for parts in content_lines_parts { |
| 44 | let line = match parts.property_namerust-analyzer cargo rrule 0.14.0 parser/content_line/content_line_parts/ContentLineCaptures#property_name. { |
| 45 | PropertyNamerust-analyzer cargo rrule 0.14.0 parser/content_line/PropertyName#::RRulerust-analyzer cargo rrule 0.14.0 parser/content_line/PropertyName#RRule# => { |
| 46 | let rrule = RRulerust-analyzer cargo rrule 0.14.0 core/rrule/RRule#::try_fromrust-analyzer cargo rrule 0.14.0 parser/content_line/rule_content_line/impl#[`RRule<Unvalidated>`][`TryFrom<ContentLineCaptures<'_>>`]try_from().(parts)?rust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`][Try]branch().; |
| 47 | ContentLinerust-analyzer cargo rrule 0.14.0 parser/content_line/ContentLine#::RRulerust-analyzer cargo rrule 0.14.0 parser/content_line/ContentLine#RRule#(rrule) |
| 48 | } |
| 49 | PropertyNamerust-analyzer cargo rrule 0.14.0 parser/content_line/PropertyName#::ExRulerust-analyzer cargo rrule 0.14.0 parser/content_line/PropertyName#ExRule# => { |
| 50 | let rrule = RRulerust-analyzer cargo rrule 0.14.0 core/rrule/RRule#::try_fromrust-analyzer cargo rrule 0.14.0 parser/content_line/rule_content_line/impl#[`RRule<Unvalidated>`][`TryFrom<ContentLineCaptures<'_>>`]try_from().(parts)?rust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`][Try]branch().; |
| 51 | ContentLinerust-analyzer cargo rrule 0.14.0 parser/content_line/ContentLine#::ExRulerust-analyzer cargo rrule 0.14.0 parser/content_line/ContentLine#ExRule#(rrule) |
| 52 | } |
| 53 | PropertyNamerust-analyzer cargo rrule 0.14.0 parser/content_line/PropertyName#::RDaterust-analyzer cargo rrule 0.14.0 parser/content_line/PropertyName#RDate# => ContentLinerust-analyzer cargo rrule 0.14.0 parser/content_line/ContentLine#::RDaterust-analyzer cargo rrule 0.14.0 parser/content_line/ContentLine#RDate#(TryFromrust-analyzer cargo core https://github.com/rust-lang/rust/library/core convert/TryFrom#::try_fromrust-analyzer cargo rrule 0.14.0 parser/content_line/date_content_line/impl#[`Vec<chrono::DateTime<Tz>>`][`TryFrom<ContentLineCaptures<'_>>`]try_from().(parts)?rust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`][Try]branch().), |
| 54 | PropertyNamerust-analyzer cargo rrule 0.14.0 parser/content_line/PropertyName#::ExDaterust-analyzer cargo rrule 0.14.0 parser/content_line/PropertyName#ExDate# => ContentLinerust-analyzer cargo rrule 0.14.0 parser/content_line/ContentLine#::ExDaterust-analyzer cargo rrule 0.14.0 parser/content_line/ContentLine#ExDate#(TryFromrust-analyzer cargo core https://github.com/rust-lang/rust/library/core convert/TryFrom#::try_fromrust-analyzer cargo rrule 0.14.0 parser/content_line/date_content_line/impl#[`Vec<chrono::DateTime<Tz>>`][`TryFrom<ContentLineCaptures<'_>>`]try_from().(parts)?rust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`][Try]branch().), |
| 55 | PropertyNamerust-analyzer cargo rrule 0.14.0 parser/content_line/PropertyName#::DtStartrust-analyzer cargo rrule 0.14.0 parser/content_line/PropertyName#DtStart# => { |
| 56 | // Nothing to do |
| 57 | continue; |
| 58 | } |
| 59 | }; |
| 60 | content_lines.pushrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/impl#[`Vec<T, A>`]push().(line); |
| 61 | } |
| 62 | |
| 63 | // Need to be at least one `RDATE` or `RRULE` |
| 64 | if !rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/bit/impl#[bool][Not]not().content_lines |
| 65 | .iterrust-analyzer cargo core https://github.com/rust-lang/rust/library/core slice/impl#[`[T]`]iter().() |
| 66 | .anyrust-analyzer cargo core https://github.com/rust-lang/rust/library/core slice/iter/impl#[`Iter<'a, T>`][Iterator]any().(|line| matchesrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/matches!!(line, ContentLinerust-analyzer cargo rrule 0.14.0 parser/content_line/ContentLine#::RRulerust-analyzer cargo rrule 0.14.0 parser/content_line/ContentLine#RRule#(_) | ContentLinerust-analyzer cargo rrule 0.14.0 parser/content_line/ContentLine#::RDaterust-analyzer cargo rrule 0.14.0 parser/content_line/ContentLine#RDate#(_))) |
| 67 | { |
| 68 | return Errrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#Err#(ParseErrorrust-analyzer cargo rrule 0.14.0 parser/error/ParseError#::MissingDateGenerationRulesrust-analyzer cargo rrule 0.14.0 parser/error/ParseError#MissingDateGenerationRules#); |
| 69 | } |
| 70 | |
| 71 | Okrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#Ok#(Selfrust-analyzer cargo rrule 0.14.0 parser/impl#[Grammar][FromStr] { |
| 72 | startrust-analyzer cargo rrule 0.14.0 parser/Grammar#start., |
| 73 | content_linesrust-analyzer cargo rrule 0.14.0 parser/Grammar#content_lines., |
| 74 | }) |
| 75 | } |
| 76 | } |
| 77 | |
| 78 | #[cfg(test)] |
| 79 | mod testrust-analyzer cargo rrule 0.14.0 parser/test/ { |
| 80 | use chronorust-analyzer cargo chrono 0.4.40 crate/::{TimeZonerust-analyzer cargo chrono 0.4.40 offset/TimeZone#, Weekdayrust-analyzer cargo chrono 0.4.40 weekday/Weekday#}; |
| 81 | |
| 82 | use superrust-analyzer cargo rrule 0.14.0 parser/::*; |
| 83 | use craterust-analyzer cargo rrule 0.14.0 crate/::{corerust-analyzer cargo rrule 0.14.0 core/::Tzrust-analyzer cargo rrule 0.14.0 core/timezone/Tz#, parserrust-analyzer cargo rrule 0.14.0 parser/::content_linerust-analyzer cargo rrule 0.14.0 parser/content_line/::ContentLinerust-analyzer cargo rrule 0.14.0 parser/content_line/ContentLine#, Frequencyrust-analyzer cargo rrule 0.14.0 core/rrule/Frequency#, NWeekdayrust-analyzer cargo rrule 0.14.0 core/rrule/NWeekday#, RRulerust-analyzer cargo rrule 0.14.0 core/rrule/RRule#}; |
| 84 | |
| 85 | const UTCrust-analyzer cargo rrule 0.14.0 parser/test/UTC.: Tzrust-analyzer cargo rrule 0.14.0 core/timezone/Tz# = Tzrust-analyzer cargo rrule 0.14.0 core/timezone/Tz#::UTCrust-analyzer cargo rrule 0.14.0 core/timezone/impl#[Tz]UTC.; |
| 86 | const BERLINrust-analyzer cargo rrule 0.14.0 parser/test/BERLIN.: Tzrust-analyzer cargo rrule 0.14.0 core/timezone/Tz# = Tzrust-analyzer cargo rrule 0.14.0 core/timezone/Tz#::Europe__Berlinrust-analyzer cargo rrule 0.14.0 core/timezone/impl#[Tz]Europe__Berlin.; |
| 87 | |
| 88 | #[testrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/test:] |
| 89 | fn parses_valid_input_to_grammarrust-analyzer cargo rrule 0.14.0 parser/test/parses_valid_input_to_grammar().() { |
| 90 | let tests = [ |
| 91 | ( |
| 92 | "DTSTART:19970902T090000Z\nRRULE:FREQ=YEARLY;COUNT=3\n", Grammarrust-analyzer cargo rrule 0.14.0 parser/Grammar# { |
| 93 | startrust-analyzer cargo rrule 0.14.0 parser/Grammar#start.: Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#(StartDateContentLinerust-analyzer cargo rrule 0.14.0 parser/content_line/start_date_content_line/StartDateContentLine# { datetimerust-analyzer cargo rrule 0.14.0 parser/content_line/start_date_content_line/StartDateContentLine#datetime.: UTCrust-analyzer cargo rrule 0.14.0 parser/test/UTC..with_ymd_and_hmsrust-analyzer cargo chrono 0.4.40 offset/TimeZone#with_ymd_and_hms().(1997, 9, 2,9, 0, 0).unwraprust-analyzer cargo chrono 0.4.40 offset/impl#[`LocalResult<T>`]unwrap().(), timezonerust-analyzer cargo rrule 0.14.0 parser/content_line/start_date_content_line/StartDateContentLine#timezone.: Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#(UTCrust-analyzer cargo rrule 0.14.0 parser/test/UTC.), valuerust-analyzer cargo rrule 0.14.0 parser/content_line/start_date_content_line/StartDateContentLine#value.: "DATE-TIME" }), |
| 94 | content_linesrust-analyzer cargo rrule 0.14.0 parser/Grammar#content_lines.: vecrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc macros/vec!![ |
| 95 | ContentLinerust-analyzer cargo rrule 0.14.0 parser/content_line/ContentLine#::RRulerust-analyzer cargo rrule 0.14.0 parser/content_line/ContentLine#RRule#(RRulerust-analyzer cargo rrule 0.14.0 core/rrule/RRule# { |
| 96 | freqrust-analyzer cargo rrule 0.14.0 core/rrule/RRule#freq.: Frequencyrust-analyzer cargo rrule 0.14.0 core/rrule/Frequency#::Yearlyrust-analyzer cargo rrule 0.14.0 core/rrule/Frequency#Yearly#, |
| 97 | countrust-analyzer cargo rrule 0.14.0 core/rrule/RRule#count.: Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#(3), |
| 98 | ..Defaultrust-analyzer cargo core https://github.com/rust-lang/rust/library/core default/Default#::defaultrust-analyzer cargo rrule 0.14.0 core/rrule/impl#[`RRule<Unvalidated>`][Default]default().() |
| 99 | }) |
| 100 | ] |
| 101 | } |
| 102 | ), |
| 103 | ("DTSTART:20120201T093000Z\nRRULE:FREQ=WEEKLY;INTERVAL=5;UNTIL=20130130T230000Z;BYDAY=MO,FR", Grammarrust-analyzer cargo rrule 0.14.0 parser/Grammar# { |
| 104 | startrust-analyzer cargo rrule 0.14.0 parser/Grammar#start.: Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#(StartDateContentLinerust-analyzer cargo rrule 0.14.0 parser/content_line/start_date_content_line/StartDateContentLine# { datetimerust-analyzer cargo rrule 0.14.0 parser/content_line/start_date_content_line/StartDateContentLine#datetime.: UTCrust-analyzer cargo rrule 0.14.0 parser/test/UTC..with_ymd_and_hmsrust-analyzer cargo chrono 0.4.40 offset/TimeZone#with_ymd_and_hms().(2012, 2, 1,9, 30, 0).unwraprust-analyzer cargo chrono 0.4.40 offset/impl#[`LocalResult<T>`]unwrap().(), timezonerust-analyzer cargo rrule 0.14.0 parser/content_line/start_date_content_line/StartDateContentLine#timezone.: Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#(UTCrust-analyzer cargo rrule 0.14.0 parser/test/UTC.), valuerust-analyzer cargo rrule 0.14.0 parser/content_line/start_date_content_line/StartDateContentLine#value.: "DATE-TIME" }), |
| 105 | content_linesrust-analyzer cargo rrule 0.14.0 parser/Grammar#content_lines.: vecrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc macros/vec!![ |
| 106 | ContentLinerust-analyzer cargo rrule 0.14.0 parser/content_line/ContentLine#::RRulerust-analyzer cargo rrule 0.14.0 parser/content_line/ContentLine#RRule#(RRulerust-analyzer cargo rrule 0.14.0 core/rrule/RRule# { |
| 107 | freqrust-analyzer cargo rrule 0.14.0 core/rrule/RRule#freq.: Frequencyrust-analyzer cargo rrule 0.14.0 core/rrule/Frequency#::Weeklyrust-analyzer cargo rrule 0.14.0 core/rrule/Frequency#Weekly#, |
| 108 | intervalrust-analyzer cargo rrule 0.14.0 core/rrule/RRule#interval.: 5, |
| 109 | untilrust-analyzer cargo rrule 0.14.0 core/rrule/RRule#until.: Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#(UTCrust-analyzer cargo rrule 0.14.0 parser/test/UTC..with_ymd_and_hmsrust-analyzer cargo chrono 0.4.40 offset/TimeZone#with_ymd_and_hms().(2013, 1, 30,23, 0, 0).unwraprust-analyzer cargo chrono 0.4.40 offset/impl#[`LocalResult<T>`]unwrap().()), |
| 110 | by_weekdayrust-analyzer cargo rrule 0.14.0 core/rrule/RRule#by_weekday.: vecrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc macros/vec!![NWeekdayrust-analyzer cargo rrule 0.14.0 core/rrule/NWeekday#::Everyrust-analyzer cargo rrule 0.14.0 core/rrule/NWeekday#Every#(Weekdayrust-analyzer cargo chrono 0.4.40 weekday/Weekday#::Monrust-analyzer cargo chrono 0.4.40 weekday/Weekday#Mon#), NWeekdayrust-analyzer cargo rrule 0.14.0 core/rrule/NWeekday#::Everyrust-analyzer cargo rrule 0.14.0 core/rrule/NWeekday#Every#(Weekdayrust-analyzer cargo chrono 0.4.40 weekday/Weekday#::Frirust-analyzer cargo chrono 0.4.40 weekday/Weekday#Fri#)], |
| 111 | ..Defaultrust-analyzer cargo core https://github.com/rust-lang/rust/library/core default/Default#::defaultrust-analyzer cargo rrule 0.14.0 core/rrule/impl#[`RRule<Unvalidated>`][Default]default().() |
| 112 | }) |
| 113 | ] |
| 114 | }), |
| 115 | ("DTSTART:20120201T120000Z\nRRULE:FREQ=DAILY;COUNT=5\nEXDATE;TZID=Europe/Berlin:20120202T130000,20120203T130000", Grammarrust-analyzer cargo rrule 0.14.0 parser/Grammar# { |
| 116 | startrust-analyzer cargo rrule 0.14.0 parser/Grammar#start.: Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#(StartDateContentLinerust-analyzer cargo rrule 0.14.0 parser/content_line/start_date_content_line/StartDateContentLine# { datetimerust-analyzer cargo rrule 0.14.0 parser/content_line/start_date_content_line/StartDateContentLine#datetime.: UTCrust-analyzer cargo rrule 0.14.0 parser/test/UTC..with_ymd_and_hmsrust-analyzer cargo chrono 0.4.40 offset/TimeZone#with_ymd_and_hms().(2012, 2, 1,12, 0, 0).unwraprust-analyzer cargo chrono 0.4.40 offset/impl#[`LocalResult<T>`]unwrap().(), timezonerust-analyzer cargo rrule 0.14.0 parser/content_line/start_date_content_line/StartDateContentLine#timezone.: Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#(UTCrust-analyzer cargo rrule 0.14.0 parser/test/UTC.), valuerust-analyzer cargo rrule 0.14.0 parser/content_line/start_date_content_line/StartDateContentLine#value.: "DATE-TIME" }), |
| 117 | content_linesrust-analyzer cargo rrule 0.14.0 parser/Grammar#content_lines.: vecrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc macros/vec!![ |
| 118 | ContentLinerust-analyzer cargo rrule 0.14.0 parser/content_line/ContentLine#::RRulerust-analyzer cargo rrule 0.14.0 parser/content_line/ContentLine#RRule#(RRulerust-analyzer cargo rrule 0.14.0 core/rrule/RRule# { |
| 119 | freqrust-analyzer cargo rrule 0.14.0 core/rrule/RRule#freq.: Frequencyrust-analyzer cargo rrule 0.14.0 core/rrule/Frequency#::Dailyrust-analyzer cargo rrule 0.14.0 core/rrule/Frequency#Daily#, |
| 120 | countrust-analyzer cargo rrule 0.14.0 core/rrule/RRule#count.: Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#(5), |
| 121 | ..Defaultrust-analyzer cargo core https://github.com/rust-lang/rust/library/core default/Default#::defaultrust-analyzer cargo rrule 0.14.0 core/rrule/impl#[`RRule<Unvalidated>`][Default]default().() |
| 122 | }), |
| 123 | ContentLinerust-analyzer cargo rrule 0.14.0 parser/content_line/ContentLine#::ExDaterust-analyzer cargo rrule 0.14.0 parser/content_line/ContentLine#ExDate#(vecrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc macros/vec!![ |
| 124 | BERLINrust-analyzer cargo rrule 0.14.0 parser/test/BERLIN..with_ymd_and_hmsrust-analyzer cargo chrono 0.4.40 offset/TimeZone#with_ymd_and_hms().(2012, 2, 2,13, 0, 0).unwraprust-analyzer cargo chrono 0.4.40 offset/impl#[`LocalResult<T>`]unwrap().(), |
| 125 | BERLINrust-analyzer cargo rrule 0.14.0 parser/test/BERLIN..with_ymd_and_hmsrust-analyzer cargo chrono 0.4.40 offset/TimeZone#with_ymd_and_hms().(2012, 2, 3,13, 0, 0).unwraprust-analyzer cargo chrono 0.4.40 offset/impl#[`LocalResult<T>`]unwrap().(), |
| 126 | ]) |
| 127 | ] |
| 128 | }), |
| 129 | ("DTSTART:20120201T120000Z\nRRULE:FREQ=DAILY;COUNT=5\nEXDATE;TZID=Europe/Berlin:20120202T130000,20120203T130000\nEXRULE:FREQ=WEEKLY;COUNT=10", Grammarrust-analyzer cargo rrule 0.14.0 parser/Grammar# { |
| 130 | startrust-analyzer cargo rrule 0.14.0 parser/Grammar#start.: Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#(StartDateContentLinerust-analyzer cargo rrule 0.14.0 parser/content_line/start_date_content_line/StartDateContentLine# { datetimerust-analyzer cargo rrule 0.14.0 parser/content_line/start_date_content_line/StartDateContentLine#datetime.: UTCrust-analyzer cargo rrule 0.14.0 parser/test/UTC..with_ymd_and_hmsrust-analyzer cargo chrono 0.4.40 offset/TimeZone#with_ymd_and_hms().(2012, 2, 1,12, 0, 0).unwraprust-analyzer cargo chrono 0.4.40 offset/impl#[`LocalResult<T>`]unwrap().(), timezonerust-analyzer cargo rrule 0.14.0 parser/content_line/start_date_content_line/StartDateContentLine#timezone.: Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#(UTCrust-analyzer cargo rrule 0.14.0 parser/test/UTC.), valuerust-analyzer cargo rrule 0.14.0 parser/content_line/start_date_content_line/StartDateContentLine#value.: "DATE-TIME" }), |
| 131 | content_linesrust-analyzer cargo rrule 0.14.0 parser/Grammar#content_lines.: vecrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc macros/vec!![ |
| 132 | ContentLinerust-analyzer cargo rrule 0.14.0 parser/content_line/ContentLine#::RRulerust-analyzer cargo rrule 0.14.0 parser/content_line/ContentLine#RRule#(RRulerust-analyzer cargo rrule 0.14.0 core/rrule/RRule# { |
| 133 | freqrust-analyzer cargo rrule 0.14.0 core/rrule/RRule#freq.: Frequencyrust-analyzer cargo rrule 0.14.0 core/rrule/Frequency#::Dailyrust-analyzer cargo rrule 0.14.0 core/rrule/Frequency#Daily#, |
| 134 | countrust-analyzer cargo rrule 0.14.0 core/rrule/RRule#count.: Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#(5), |
| 135 | ..Defaultrust-analyzer cargo core https://github.com/rust-lang/rust/library/core default/Default#::defaultrust-analyzer cargo rrule 0.14.0 core/rrule/impl#[`RRule<Unvalidated>`][Default]default().() |
| 136 | }), |
| 137 | ContentLinerust-analyzer cargo rrule 0.14.0 parser/content_line/ContentLine#::ExDaterust-analyzer cargo rrule 0.14.0 parser/content_line/ContentLine#ExDate#(vecrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc macros/vec!![ |
| 138 | BERLINrust-analyzer cargo rrule 0.14.0 parser/test/BERLIN..with_ymd_and_hmsrust-analyzer cargo chrono 0.4.40 offset/TimeZone#with_ymd_and_hms().(2012, 2, 2,13, 0, 0).unwraprust-analyzer cargo chrono 0.4.40 offset/impl#[`LocalResult<T>`]unwrap().(), |
| 139 | BERLINrust-analyzer cargo rrule 0.14.0 parser/test/BERLIN..with_ymd_and_hmsrust-analyzer cargo chrono 0.4.40 offset/TimeZone#with_ymd_and_hms().(2012, 2, 3,13, 0, 0).unwraprust-analyzer cargo chrono 0.4.40 offset/impl#[`LocalResult<T>`]unwrap().(), |
| 140 | ]), |
| 141 | ContentLinerust-analyzer cargo rrule 0.14.0 parser/content_line/ContentLine#::ExRulerust-analyzer cargo rrule 0.14.0 parser/content_line/ContentLine#ExRule#(RRulerust-analyzer cargo rrule 0.14.0 core/rrule/RRule# { |
| 142 | freqrust-analyzer cargo rrule 0.14.0 core/rrule/RRule#freq.: Frequencyrust-analyzer cargo rrule 0.14.0 core/rrule/Frequency#::Weeklyrust-analyzer cargo rrule 0.14.0 core/rrule/Frequency#Weekly#, |
| 143 | countrust-analyzer cargo rrule 0.14.0 core/rrule/RRule#count.: Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#(10), |
| 144 | ..Defaultrust-analyzer cargo core https://github.com/rust-lang/rust/library/core default/Default#::defaultrust-analyzer cargo rrule 0.14.0 core/rrule/impl#[`RRule<Unvalidated>`][Default]default().() |
| 145 | }), |
| 146 | ] |
| 147 | }) |
| 148 | ]; |
| 149 | for (input, expected_grammar) in tests { |
| 150 | let grammar = Grammarrust-analyzer cargo rrule 0.14.0 parser/Grammar#::from_strrust-analyzer cargo rrule 0.14.0 parser/impl#[Grammar][FromStr]from_str().(input); |
| 151 | assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(grammar, Okrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#Ok#(expected_grammar)); |
| 152 | } |
| 153 | } |
| 154 | |
| 155 | #[testrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/test:] |
| 156 | fn rejects_input_without_date_generationrust-analyzer cargo rrule 0.14.0 parser/test/rejects_input_without_date_generation().() { |
| 157 | let tests = [ |
| 158 | "DTSTART:19970902T090000Z", |
| 159 | "DTSTART:20120201T093000Z\nEXRULE:FREQ=WEEKLY;INTERVAL=5;UNTIL=20130130T230000Z;BYDAY=MO,FR", |
| 160 | "DTSTART:20120201T120000Z\nEXDATE;TZID=Europe/Berlin:20120202T130000,20120203T130000", |
| 161 | "DTSTART:20120201T120000Z\nEXRULE:FREQ=DAILY;COUNT=5\nEXDATE;TZID=Europe/Berlin:20120202T130000,20120203T130000" |
| 162 | ]; |
| 163 | for input in tests { |
| 164 | let res = Grammarrust-analyzer cargo rrule 0.14.0 parser/Grammar#::from_strrust-analyzer cargo rrule 0.14.0 parser/impl#[Grammar][FromStr]from_str().(input); |
| 165 | assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(res, Errrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#Err#(ParseErrorrust-analyzer cargo rrule 0.14.0 parser/error/ParseError#::MissingDateGenerationRulesrust-analyzer cargo rrule 0.14.0 parser/error/ParseError#MissingDateGenerationRules#)); |
| 166 | } |
| 167 | } |
| 168 | |
| 169 | #[testrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/test:] |
| 170 | fn allows_input_without_start_daterust-analyzer cargo rrule 0.14.0 parser/test/allows_input_without_start_date().() { |
| 171 | let tests = [ |
| 172 | "RRULE:FREQ=WEEKLY;INTERVAL=5;UNTIL=20130130T230000Z;BYDAY=MO,FR", |
| 173 | "RDATE;TZID=Europe/Berlin:20120202T130000,20120203T130000", |
| 174 | "RRULE:FREQ=DAILY;COUNT=5\nEXDATE;TZID=Europe/Berlin:20120202T130000,20120203T130000", |
| 175 | ]; |
| 176 | for input in tests { |
| 177 | let res = Grammarrust-analyzer cargo rrule 0.14.0 parser/Grammar#::from_strrust-analyzer cargo rrule 0.14.0 parser/impl#[Grammar][FromStr]from_str().(input); |
| 178 | assertrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/assert!!(res.is_okrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]is_ok().()); |
| 179 | } |
| 180 | } |
| 181 | } |