| 1 | use stdrust-analyzer cargo std https://github.com/rust-lang/rust/library/std crate/::opsrust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/::RangeInclusiverust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/range/RangeInclusive#; |
| 2 | |
| 3 | use craterust-analyzer cargo rrule 0.14.0 crate/::{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#, Tzrust-analyzer cargo rrule 0.14.0 core/timezone/Tz#, Unvalidatedrust-analyzer cargo rrule 0.14.0 core/Unvalidated#}; |
| 4 | |
| 5 | use superrust-analyzer cargo rrule 0.14.0 validator/::ValidationErrorrust-analyzer cargo rrule 0.14.0 validator/error/ValidationError#; |
| 6 | |
| 7 | /// Range of values that a month can be. |
| 8 | /// Range: `1..=12` |
| 9 | pub(craterust-analyzer cargo rrule 0.14.0 crate/) static MONTH_RANGErust-analyzer cargo rrule 0.14.0 validator/validate_rrule/MONTH_RANGE.: RangeInclusiverust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/range/RangeInclusive#<u8> = 1..=rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/range/RangeInclusive#12; |
| 10 | |
| 11 | /// Range of values that a year can be. |
| 12 | /// Range: `-10_000..=10_000` |
| 13 | pub(craterust-analyzer cargo rrule 0.14.0 crate/) static YEAR_RANGErust-analyzer cargo rrule 0.14.0 validator/validate_rrule/YEAR_RANGE.: RangeInclusiverust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/range/RangeInclusive#<i32> = -rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[i32][Neg]neg().10_000..=rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/range/RangeInclusive#10_000; |
| 14 | |
| 15 | type Validatorrust-analyzer cargo rrule 0.14.0 validator/validate_rrule/Validator# = |
| 16 | &'static dyn Fnrust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/function/Fn#(&RRulerust-analyzer cargo rrule 0.14.0 core/rrule/RRule#<Unvalidatedrust-analyzer cargo rrule 0.14.0 core/Unvalidated#>, &chronorust-analyzer cargo chrono 0.4.40 crate/::DateTimerust-analyzer cargo chrono 0.4.40 datetime/DateTime#<Tzrust-analyzer cargo rrule 0.14.0 core/timezone/Tz#>) -> Resultrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#<(), ValidationErrorrust-analyzer cargo rrule 0.14.0 validator/error/ValidationError#>; |
| 17 | |
| 18 | const VALIDATION_PIPELINErust-analyzer cargo rrule 0.14.0 validator/validate_rrule/VALIDATION_PIPELINE.: [Validatorrust-analyzer cargo rrule 0.14.0 validator/validate_rrule/Validator#; 11] = [ |
| 19 | &validate_untilrust-analyzer cargo rrule 0.14.0 validator/validate_rrule/validate_until()., |
| 20 | &validate_by_set_posrust-analyzer cargo rrule 0.14.0 validator/validate_rrule/validate_by_set_pos()., |
| 21 | &validate_by_monthrust-analyzer cargo rrule 0.14.0 validator/validate_rrule/validate_by_month()., |
| 22 | &validate_by_month_dayrust-analyzer cargo rrule 0.14.0 validator/validate_rrule/validate_by_month_day()., |
| 23 | &validate_by_year_dayrust-analyzer cargo rrule 0.14.0 validator/validate_rrule/validate_by_year_day()., |
| 24 | &validate_by_week_numberrust-analyzer cargo rrule 0.14.0 validator/validate_rrule/validate_by_week_number()., |
| 25 | &validate_by_weekdayrust-analyzer cargo rrule 0.14.0 validator/validate_rrule/validate_by_weekday()., |
| 26 | &validate_by_hourrust-analyzer cargo rrule 0.14.0 validator/validate_rrule/validate_by_hour()., |
| 27 | &validate_by_minuterust-analyzer cargo rrule 0.14.0 validator/validate_rrule/validate_by_minute()., |
| 28 | &validate_by_secondrust-analyzer cargo rrule 0.14.0 validator/validate_rrule/validate_by_second()., |
| 29 | &validate_by_easterrust-analyzer cargo rrule 0.14.0 validator/validate_rrule/validate_by_easter()., |
| 30 | ]; |
| 31 | |
| 32 | /// Check if rules are valid as defined by the RFC and crate limitations. |
| 33 | /// It checks all values in the [`RRule`] and makes sure that they are in |
| 34 | /// the accepted ranges. If the function returns `Ok`, no errors where found. |
| 35 | /// |
| 36 | /// This check should always be done and just enforces limits set by the standard. |
| 37 | /// Validation will always be enforced and can not be disabled using feature flags. |
| 38 | pub(craterust-analyzer cargo rrule 0.14.0 crate/) fn validate_rrule_forcedrust-analyzer cargo rrule 0.14.0 validator/validate_rrule/validate_rrule_forced().( |
| 39 | rrule: &RRulerust-analyzer cargo rrule 0.14.0 core/rrule/RRule#<Unvalidatedrust-analyzer cargo rrule 0.14.0 core/Unvalidated#>, |
| 40 | dt_start: &chronorust-analyzer cargo chrono 0.4.40 crate/::DateTimerust-analyzer cargo chrono 0.4.40 datetime/DateTime#<Tzrust-analyzer cargo rrule 0.14.0 core/timezone/Tz#>, |
| 41 | ) -> Resultrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#<(), ValidationErrorrust-analyzer cargo rrule 0.14.0 validator/error/ValidationError#> { |
| 42 | VALIDATION_PIPELINErust-analyzer cargo rrule 0.14.0 validator/validate_rrule/VALIDATION_PIPELINE. |
| 43 | .into_iterrust-analyzer cargo core https://github.com/rust-lang/rust/library/core array/iter/impl#[`[T; N]`][IntoIterator]into_iter().() |
| 44 | .try_for_eachrust-analyzer cargo core https://github.com/rust-lang/rust/library/core iter/traits/iterator/Iterator#try_for_each().(|validator| validator(rrule, dt_start)) |
| 45 | } |
| 46 | |
| 47 | // Until: |
| 48 | // - Timezones are correctly synced as specified in the RFC |
| 49 | // - Value should be later than `dt_start`. |
| 50 | fn validate_untilrust-analyzer cargo rrule 0.14.0 validator/validate_rrule/validate_until().( |
| 51 | rrule: &RRulerust-analyzer cargo rrule 0.14.0 core/rrule/RRule#<Unvalidatedrust-analyzer cargo rrule 0.14.0 core/Unvalidated#>, |
| 52 | dt_start: &chronorust-analyzer cargo chrono 0.4.40 crate/::DateTimerust-analyzer cargo chrono 0.4.40 datetime/DateTime#<Tzrust-analyzer cargo rrule 0.14.0 core/timezone/Tz#>, |
| 53 | ) -> Resultrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#<(), ValidationErrorrust-analyzer cargo rrule 0.14.0 validator/error/ValidationError#> { |
| 54 | match rrule.untilrust-analyzer cargo rrule 0.14.0 core/rrule/RRule#until. { |
| 55 | Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#(until) => { |
| 56 | match dt_start.timezonerust-analyzer cargo chrono 0.4.40 datetime/impl#[`DateTime<Tz>`]timezone().() { |
| 57 | Tzrust-analyzer cargo rrule 0.14.0 core/timezone/Tz#::Localrust-analyzer cargo rrule 0.14.0 core/timezone/Tz#Local#(_) => { |
| 58 | let allowed_timezones = vecrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc macros/vec!![Tzrust-analyzer cargo rrule 0.14.0 core/timezone/Tz#::LOCALrust-analyzer cargo rrule 0.14.0 core/timezone/impl#[Tz]LOCAL., Tzrust-analyzer cargo rrule 0.14.0 core/timezone/Tz#::UTCrust-analyzer cargo rrule 0.14.0 core/timezone/impl#[Tz]UTC.]; |
| 59 | if !rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/bit/impl#[bool][Not]not().allowed_timezones.containsrust-analyzer cargo core https://github.com/rust-lang/rust/library/core slice/impl#[`[T]`]contains().(&until.timezonerust-analyzer cargo chrono 0.4.40 datetime/impl#[`DateTime<Tz>`]timezone().()) { |
| 60 | return Errrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#Err#(ValidationErrorrust-analyzer cargo rrule 0.14.0 validator/error/ValidationError#::DtStartUntilMismatchTimezonerust-analyzer cargo rrule 0.14.0 validator/error/ValidationError#DtStartUntilMismatchTimezone# { |
| 61 | dt_start_tzrust-analyzer cargo rrule 0.14.0 validator/error/ValidationError#DtStartUntilMismatchTimezone#dt_start_tz.: dt_start.timezonerust-analyzer cargo chrono 0.4.40 datetime/impl#[`DateTime<Tz>`]timezone().().namerust-analyzer cargo rrule 0.14.0 core/timezone/impl#[Tz]name().().intorust-analyzer cargo core https://github.com/rust-lang/rust/library/core convert/impl#[T][`Into<U>`]into().(), |
| 62 | until_tzrust-analyzer cargo rrule 0.14.0 validator/error/ValidationError#DtStartUntilMismatchTimezone#until_tz.: until.timezonerust-analyzer cargo chrono 0.4.40 datetime/impl#[`DateTime<Tz>`]timezone().().namerust-analyzer cargo rrule 0.14.0 core/timezone/impl#[Tz]name().().intorust-analyzer cargo core https://github.com/rust-lang/rust/library/core convert/impl#[T][`Into<U>`]into().(), |
| 63 | expectedrust-analyzer cargo rrule 0.14.0 validator/error/ValidationError#DtStartUntilMismatchTimezone#expected.: allowed_timezones |
| 64 | .into_iterrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/impl#[`Vec<T, A>`][IntoIterator]into_iter().() |
| 65 | .maprust-analyzer cargo core https://github.com/rust-lang/rust/library/core iter/traits/iterator/Iterator#map().(|tz| tz.namerust-analyzer cargo rrule 0.14.0 core/timezone/impl#[Tz]name().().intorust-analyzer cargo core https://github.com/rust-lang/rust/library/core convert/impl#[T][`Into<U>`]into().()) |
| 66 | .collectrust-analyzer cargo core https://github.com/rust-lang/rust/library/core iter/traits/iterator/Iterator#collect().(), |
| 67 | }); |
| 68 | } |
| 69 | } |
| 70 | Tzrust-analyzer cargo rrule 0.14.0 core/timezone/Tz#::Tzrust-analyzer cargo rrule 0.14.0 core/timezone/Tz#Tz#(_) => { |
| 71 | if until.timezonerust-analyzer cargo chrono 0.4.40 datetime/impl#[`DateTime<Tz>`]timezone().() rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/PartialEq#ne().!=rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/PartialEq#ne(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/PartialEq#ne().Tzrust-analyzer cargo rrule 0.14.0 core/timezone/Tz#::UTCrust-analyzer cargo rrule 0.14.0 core/timezone/impl#[Tz]UTC. { |
| 72 | return Errrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#Err#(ValidationErrorrust-analyzer cargo rrule 0.14.0 validator/error/ValidationError#::DtStartUntilMismatchTimezonerust-analyzer cargo rrule 0.14.0 validator/error/ValidationError#DtStartUntilMismatchTimezone# { |
| 73 | dt_start_tzrust-analyzer cargo rrule 0.14.0 validator/error/ValidationError#DtStartUntilMismatchTimezone#dt_start_tz.: dt_start.timezonerust-analyzer cargo chrono 0.4.40 datetime/impl#[`DateTime<Tz>`]timezone().().namerust-analyzer cargo rrule 0.14.0 core/timezone/impl#[Tz]name().().intorust-analyzer cargo core https://github.com/rust-lang/rust/library/core convert/impl#[T][`Into<U>`]into().(), |
| 74 | until_tzrust-analyzer cargo rrule 0.14.0 validator/error/ValidationError#DtStartUntilMismatchTimezone#until_tz.: until.timezonerust-analyzer cargo chrono 0.4.40 datetime/impl#[`DateTime<Tz>`]timezone().().namerust-analyzer cargo rrule 0.14.0 core/timezone/impl#[Tz]name().().intorust-analyzer cargo core https://github.com/rust-lang/rust/library/core convert/impl#[T][`Into<U>`]into().(), |
| 75 | expectedrust-analyzer cargo rrule 0.14.0 validator/error/ValidationError#DtStartUntilMismatchTimezone#expected.: vecrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc macros/vec!!["UTC".intorust-analyzer cargo core https://github.com/rust-lang/rust/library/core convert/impl#[T][`Into<U>`]into().()], |
| 76 | }); |
| 77 | } |
| 78 | } |
| 79 | } |
| 80 | |
| 81 | if until rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/PartialOrd#lt().<rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/PartialOrd#lt(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/PartialOrd#lt().*rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/deref/impl#[`&T`][Deref]deref().dt_start { |
| 82 | return Errrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#Err#(ValidationErrorrust-analyzer cargo rrule 0.14.0 validator/error/ValidationError#::UntilBeforeStartrust-analyzer cargo rrule 0.14.0 validator/error/ValidationError#UntilBeforeStart# { |
| 83 | untilrust-analyzer cargo rrule 0.14.0 validator/error/ValidationError#UntilBeforeStart#until.: until.to_rfc3339rust-analyzer cargo chrono 0.4.40 datetime/impl#[`DateTime<Tz>`]to_rfc3339().(), |
| 84 | dt_startrust-analyzer cargo rrule 0.14.0 validator/error/ValidationError#UntilBeforeStart#dt_start.: dt_start.to_rfc3339rust-analyzer cargo chrono 0.4.40 datetime/impl#[`DateTime<Tz>`]to_rfc3339().(), |
| 85 | }); |
| 86 | } |
| 87 | Okrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#Ok#(()) |
| 88 | } |
| 89 | _ => Okrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#Ok#(()), |
| 90 | } |
| 91 | } |
| 92 | |
| 93 | // By_set_pos: |
| 94 | // - Can be a value from -366 to -1 and 1 to 366 depending on `freq` |
| 95 | fn validate_by_set_posrust-analyzer cargo rrule 0.14.0 validator/validate_rrule/validate_by_set_pos().( |
| 96 | rrule: &RRulerust-analyzer cargo rrule 0.14.0 core/rrule/RRule#<Unvalidatedrust-analyzer cargo rrule 0.14.0 core/Unvalidated#>, |
| 97 | _dt_start: &chronorust-analyzer cargo chrono 0.4.40 crate/::DateTimerust-analyzer cargo chrono 0.4.40 datetime/DateTime#<Tzrust-analyzer cargo rrule 0.14.0 core/timezone/Tz#>, |
| 98 | ) -> Resultrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#<(), ValidationErrorrust-analyzer cargo rrule 0.14.0 validator/error/ValidationError#> { |
| 99 | validate_not_equal_for_vecrust-analyzer cargo rrule 0.14.0 validator/validate_rrule/validate_not_equal_for_vec().(&0, &rrule.by_set_posrust-analyzer cargo rrule 0.14.0 core/rrule/RRule#by_set_pos., "BYSETPOS")?rust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`][Try]branch().; |
| 100 | let range = match rrule.freqrust-analyzer cargo rrule 0.14.0 core/rrule/RRule#freq. { |
| 101 | Frequencyrust-analyzer cargo rrule 0.14.0 core/rrule/Frequency#::Yearlyrust-analyzer cargo rrule 0.14.0 core/rrule/Frequency#Yearly# | Frequencyrust-analyzer cargo rrule 0.14.0 core/rrule/Frequency#::Dailyrust-analyzer cargo rrule 0.14.0 core/rrule/Frequency#Daily# => -rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[i32][Neg]neg().366..=rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/range/RangeInclusive#366, // TODO is the daily range correct? |
| 102 | Frequencyrust-analyzer cargo rrule 0.14.0 core/rrule/Frequency#::Monthlyrust-analyzer cargo rrule 0.14.0 core/rrule/Frequency#Monthly# => -rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[i32][Neg]neg().31..=rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/range/RangeInclusive#31, |
| 103 | Frequencyrust-analyzer cargo rrule 0.14.0 core/rrule/Frequency#::Weeklyrust-analyzer cargo rrule 0.14.0 core/rrule/Frequency#Weekly# => -rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[i32][Neg]neg().53..=rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/range/RangeInclusive#53, |
| 104 | Frequencyrust-analyzer cargo rrule 0.14.0 core/rrule/Frequency#::Hourlyrust-analyzer cargo rrule 0.14.0 core/rrule/Frequency#Hourly# => -rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[i32][Neg]neg().24..=rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/range/RangeInclusive#24, |
| 105 | Frequencyrust-analyzer cargo rrule 0.14.0 core/rrule/Frequency#::Minutelyrust-analyzer cargo rrule 0.14.0 core/rrule/Frequency#Minutely# | Frequencyrust-analyzer cargo rrule 0.14.0 core/rrule/Frequency#::Secondlyrust-analyzer cargo rrule 0.14.0 core/rrule/Frequency#Secondly# => -rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[i32][Neg]neg().60..=rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/range/RangeInclusive#60, |
| 106 | }; |
| 107 | if let Errrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#Err#(value) = validate_range_for_vec_errorrust-analyzer cargo rrule 0.14.0 validator/validate_rrule/validate_range_for_vec_error().(&range, &rrule.by_set_posrust-analyzer cargo rrule 0.14.0 core/rrule/RRule#by_set_pos.) { |
| 108 | return Errrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#Err#(ValidationErrorrust-analyzer cargo rrule 0.14.0 validator/error/ValidationError#::InvalidFieldValueRangeWithFreqrust-analyzer cargo rrule 0.14.0 validator/error/ValidationError#InvalidFieldValueRangeWithFreq# { |
| 109 | fieldrust-analyzer cargo rrule 0.14.0 validator/error/ValidationError#InvalidFieldValueRangeWithFreq#field.: "BYSETPOS".intorust-analyzer cargo core https://github.com/rust-lang/rust/library/core convert/impl#[T][`Into<U>`]into().(), |
| 110 | valuerust-analyzer cargo rrule 0.14.0 validator/error/ValidationError#InvalidFieldValueRangeWithFreq#value.: value.to_stringrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/impl#[T][ToString]to_string().(), |
| 111 | freqrust-analyzer cargo rrule 0.14.0 validator/error/ValidationError#InvalidFieldValueRangeWithFreq#freq.: rrule.freqrust-analyzer cargo rrule 0.14.0 core/rrule/RRule#freq., |
| 112 | start_idxrust-analyzer cargo rrule 0.14.0 validator/error/ValidationError#InvalidFieldValueRangeWithFreq#start_idx.: range.startrust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/range/impl#[`RangeInclusive<Idx>`]start().().to_stringrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/impl#[T][ToString]to_string().(), |
| 113 | end_idxrust-analyzer cargo rrule 0.14.0 validator/error/ValidationError#InvalidFieldValueRangeWithFreq#end_idx.: range.endrust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/range/impl#[`RangeInclusive<Idx>`]end().().to_stringrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/impl#[T][ToString]to_string().(), |
| 114 | }); |
| 115 | } |
| 116 | // - It MUST only be used in conjunction with another BYxxx rule part. |
| 117 | if !rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/bit/impl#[bool][Not]not().rrule.by_set_posrust-analyzer cargo rrule 0.14.0 core/rrule/RRule#by_set_pos..is_emptyrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/impl#[`Vec<T, A>`]is_empty().() |
| 118 | && rrule.by_easterrust-analyzer cargo rrule 0.14.0 core/rrule/RRule#by_easter..is_nonerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/impl#[`Option<T>`]is_none().() |
| 119 | && rrule.by_hourrust-analyzer cargo rrule 0.14.0 core/rrule/RRule#by_hour..is_emptyrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/impl#[`Vec<T, A>`]is_empty().() |
| 120 | && rrule.by_minuterust-analyzer cargo rrule 0.14.0 core/rrule/RRule#by_minute..is_emptyrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/impl#[`Vec<T, A>`]is_empty().() |
| 121 | && rrule.by_secondrust-analyzer cargo rrule 0.14.0 core/rrule/RRule#by_second..is_emptyrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/impl#[`Vec<T, A>`]is_empty().() |
| 122 | && rrule.by_month_dayrust-analyzer cargo rrule 0.14.0 core/rrule/RRule#by_month_day..is_emptyrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/impl#[`Vec<T, A>`]is_empty().() |
| 123 | && rrule.by_monthrust-analyzer cargo rrule 0.14.0 core/rrule/RRule#by_month..is_emptyrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/impl#[`Vec<T, A>`]is_empty().() |
| 124 | && rrule.by_year_dayrust-analyzer cargo rrule 0.14.0 core/rrule/RRule#by_year_day..is_emptyrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/impl#[`Vec<T, A>`]is_empty().() |
| 125 | && rrule.by_week_norust-analyzer cargo rrule 0.14.0 core/rrule/RRule#by_week_no..is_emptyrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/impl#[`Vec<T, A>`]is_empty().() |
| 126 | && rrule.by_weekdayrust-analyzer cargo rrule 0.14.0 core/rrule/RRule#by_weekday..is_emptyrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/impl#[`Vec<T, A>`]is_empty().() |
| 127 | { |
| 128 | return Errrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#Err#(ValidationErrorrust-analyzer cargo rrule 0.14.0 validator/error/ValidationError#::BySetPosWithoutByRulerust-analyzer cargo rrule 0.14.0 validator/error/ValidationError#BySetPosWithoutByRule#); |
| 129 | } |
| 130 | Okrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#Ok#(()) |
| 131 | } |
| 132 | |
| 133 | // By_month: |
| 134 | // - Can be a value from 1 to 12. |
| 135 | fn validate_by_monthrust-analyzer cargo rrule 0.14.0 validator/validate_rrule/validate_by_month().( |
| 136 | rrule: &RRulerust-analyzer cargo rrule 0.14.0 core/rrule/RRule#<Unvalidatedrust-analyzer cargo rrule 0.14.0 core/Unvalidated#>, |
| 137 | _dt_start: &chronorust-analyzer cargo chrono 0.4.40 crate/::DateTimerust-analyzer cargo chrono 0.4.40 datetime/DateTime#<Tzrust-analyzer cargo rrule 0.14.0 core/timezone/Tz#>, |
| 138 | ) -> Resultrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#<(), ValidationErrorrust-analyzer cargo rrule 0.14.0 validator/error/ValidationError#> { |
| 139 | validate_range_for_vecrust-analyzer cargo rrule 0.14.0 validator/validate_rrule/validate_range_for_vec().(&MONTH_RANGErust-analyzer cargo rrule 0.14.0 validator/validate_rrule/MONTH_RANGE., &rrule.by_monthrust-analyzer cargo rrule 0.14.0 core/rrule/RRule#by_month., "BYMONTH") |
| 140 | } |
| 141 | |
| 142 | // By_month_day: |
| 143 | // - Can be a value from -31 to -1 and 1 to 31. |
| 144 | fn validate_by_month_dayrust-analyzer cargo rrule 0.14.0 validator/validate_rrule/validate_by_month_day().( |
| 145 | rrule: &RRulerust-analyzer cargo rrule 0.14.0 core/rrule/RRule#<Unvalidatedrust-analyzer cargo rrule 0.14.0 core/Unvalidated#>, |
| 146 | _dt_start: &chronorust-analyzer cargo chrono 0.4.40 crate/::DateTimerust-analyzer cargo chrono 0.4.40 datetime/DateTime#<Tzrust-analyzer cargo rrule 0.14.0 core/timezone/Tz#>, |
| 147 | ) -> Resultrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#<(), ValidationErrorrust-analyzer cargo rrule 0.14.0 validator/error/ValidationError#> { |
| 148 | validate_not_equal_for_vecrust-analyzer cargo rrule 0.14.0 validator/validate_rrule/validate_not_equal_for_vec().(&0, &rrule.by_month_dayrust-analyzer cargo rrule 0.14.0 core/rrule/RRule#by_month_day., "BYMONTHDAY")?rust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`][Try]branch().; |
| 149 | validate_range_for_vecrust-analyzer cargo rrule 0.14.0 validator/validate_rrule/validate_range_for_vec().(&(-rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[i8][Neg]neg().31..=rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/range/RangeInclusive#31), &rrule.by_month_dayrust-analyzer cargo rrule 0.14.0 core/rrule/RRule#by_month_day., "BYMONTHDAY")?rust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`][Try]branch().; |
| 150 | // - MUST NOT be specified when the FREQ rule part is set to WEEKLY. |
| 151 | // Validated below |
| 152 | if !rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/bit/impl#[bool][Not]not().rrule.by_month_dayrust-analyzer cargo rrule 0.14.0 core/rrule/RRule#by_month_day..is_emptyrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/impl#[`Vec<T, A>`]is_empty().() { |
| 153 | let valid = rrule.freqrust-analyzer cargo rrule 0.14.0 core/rrule/RRule#freq. rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/PartialEq#ne().!=rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/PartialEq#ne(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/PartialEq#ne().Frequencyrust-analyzer cargo rrule 0.14.0 core/rrule/Frequency#::Weeklyrust-analyzer cargo rrule 0.14.0 core/rrule/Frequency#Weekly#; |
| 154 | if !rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/bit/impl#[bool][Not]not().valid { |
| 155 | return Errrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#Err#(ValidationErrorrust-analyzer cargo rrule 0.14.0 validator/error/ValidationError#::InvalidByRuleAndFrequencyrust-analyzer cargo rrule 0.14.0 validator/error/ValidationError#InvalidByRuleAndFrequency# { |
| 156 | by_rulerust-analyzer cargo rrule 0.14.0 validator/error/ValidationError#InvalidByRuleAndFrequency#by_rule.: "BYMONTHDAY".intorust-analyzer cargo core https://github.com/rust-lang/rust/library/core convert/impl#[T][`Into<U>`]into().(), |
| 157 | freqrust-analyzer cargo rrule 0.14.0 validator/error/ValidationError#InvalidByRuleAndFrequency#freq.: rrule.freqrust-analyzer cargo rrule 0.14.0 core/rrule/RRule#freq., |
| 158 | }); |
| 159 | } |
| 160 | } |
| 161 | Okrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#Ok#(()) |
| 162 | } |
| 163 | |
| 164 | // By_year_day: |
| 165 | // - Can be a value from -366 to -1 and 1 to 366. |
| 166 | fn validate_by_year_dayrust-analyzer cargo rrule 0.14.0 validator/validate_rrule/validate_by_year_day().( |
| 167 | rrule: &RRulerust-analyzer cargo rrule 0.14.0 core/rrule/RRule#<Unvalidatedrust-analyzer cargo rrule 0.14.0 core/Unvalidated#>, |
| 168 | _dt_start: &chronorust-analyzer cargo chrono 0.4.40 crate/::DateTimerust-analyzer cargo chrono 0.4.40 datetime/DateTime#<Tzrust-analyzer cargo rrule 0.14.0 core/timezone/Tz#>, |
| 169 | ) -> Resultrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#<(), ValidationErrorrust-analyzer cargo rrule 0.14.0 validator/error/ValidationError#> { |
| 170 | validate_not_equal_for_vecrust-analyzer cargo rrule 0.14.0 validator/validate_rrule/validate_not_equal_for_vec().(&0, &rrule.by_year_dayrust-analyzer cargo rrule 0.14.0 core/rrule/RRule#by_year_day., "BYYEARDAY")?rust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`][Try]branch().; |
| 171 | validate_range_for_vecrust-analyzer cargo rrule 0.14.0 validator/validate_rrule/validate_range_for_vec().(&(-rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[i16][Neg]neg().366..=rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/range/RangeInclusive#366), &rrule.by_year_dayrust-analyzer cargo rrule 0.14.0 core/rrule/RRule#by_year_day., "BYYEARDAY")?rust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`][Try]branch().; |
| 172 | // - MUST NOT be specified when the FREQ rule part is set to DAILY, WEEKLY, or MONTHLY. |
| 173 | // Validated below |
| 174 | if !rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/bit/impl#[bool][Not]not().rrule.by_year_dayrust-analyzer cargo rrule 0.14.0 core/rrule/RRule#by_year_day..is_emptyrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/impl#[`Vec<T, A>`]is_empty().() { |
| 175 | let valid = !rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/bit/impl#[bool][Not]not().matchesrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/matches!!( |
| 176 | rrule.freqrust-analyzer cargo rrule 0.14.0 core/rrule/RRule#freq., |
| 177 | Frequencyrust-analyzer cargo rrule 0.14.0 core/rrule/Frequency#::Monthlyrust-analyzer cargo rrule 0.14.0 core/rrule/Frequency#Monthly# | Frequencyrust-analyzer cargo rrule 0.14.0 core/rrule/Frequency#::Weeklyrust-analyzer cargo rrule 0.14.0 core/rrule/Frequency#Weekly# | Frequencyrust-analyzer cargo rrule 0.14.0 core/rrule/Frequency#::Dailyrust-analyzer cargo rrule 0.14.0 core/rrule/Frequency#Daily# |
| 178 | ); |
| 179 | if !rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/bit/impl#[bool][Not]not().valid { |
| 180 | return Errrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#Err#(ValidationErrorrust-analyzer cargo rrule 0.14.0 validator/error/ValidationError#::InvalidByRuleAndFrequencyrust-analyzer cargo rrule 0.14.0 validator/error/ValidationError#InvalidByRuleAndFrequency# { |
| 181 | by_rulerust-analyzer cargo rrule 0.14.0 validator/error/ValidationError#InvalidByRuleAndFrequency#by_rule.: "BYYEARDAY".intorust-analyzer cargo core https://github.com/rust-lang/rust/library/core convert/impl#[T][`Into<U>`]into().(), |
| 182 | freqrust-analyzer cargo rrule 0.14.0 validator/error/ValidationError#InvalidByRuleAndFrequency#freq.: rrule.freqrust-analyzer cargo rrule 0.14.0 core/rrule/RRule#freq., |
| 183 | }); |
| 184 | } |
| 185 | } |
| 186 | Okrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#Ok#(()) |
| 187 | } |
| 188 | // By_week_no: |
| 189 | // - Can be a value from -53 to -1 and 1 to 53. |
| 190 | fn validate_by_week_numberrust-analyzer cargo rrule 0.14.0 validator/validate_rrule/validate_by_week_number().( |
| 191 | rrule: &RRulerust-analyzer cargo rrule 0.14.0 core/rrule/RRule#<Unvalidatedrust-analyzer cargo rrule 0.14.0 core/Unvalidated#>, |
| 192 | _dt_start: &chronorust-analyzer cargo chrono 0.4.40 crate/::DateTimerust-analyzer cargo chrono 0.4.40 datetime/DateTime#<Tzrust-analyzer cargo rrule 0.14.0 core/timezone/Tz#>, |
| 193 | ) -> Resultrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#<(), ValidationErrorrust-analyzer cargo rrule 0.14.0 validator/error/ValidationError#> { |
| 194 | validate_not_equal_for_vecrust-analyzer cargo rrule 0.14.0 validator/validate_rrule/validate_not_equal_for_vec().(&0, &rrule.by_week_norust-analyzer cargo rrule 0.14.0 core/rrule/RRule#by_week_no., "BYWEEKNO")?rust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`][Try]branch().; |
| 195 | validate_range_for_vecrust-analyzer cargo rrule 0.14.0 validator/validate_rrule/validate_range_for_vec().(&(-rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[i8][Neg]neg().53..=rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/range/RangeInclusive#53), &rrule.by_week_norust-analyzer cargo rrule 0.14.0 core/rrule/RRule#by_week_no., "BYWEEKNO")?rust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`][Try]branch().; |
| 196 | // - MUST NOT be used when the FREQ rule part is set to anything other than YEARLY. |
| 197 | // Validated below |
| 198 | if !rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/bit/impl#[bool][Not]not().rrule.by_week_norust-analyzer cargo rrule 0.14.0 core/rrule/RRule#by_week_no..is_emptyrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/impl#[`Vec<T, A>`]is_empty().() { |
| 199 | let valid = rrule.freqrust-analyzer cargo rrule 0.14.0 core/rrule/RRule#freq. rust-analyzer cargo rrule 0.14.0 core/rrule/impl#[Frequency][`PartialEq<Self>`]eq().==rust-analyzer cargo rrule 0.14.0 core/rrule/impl#[Frequency][`PartialEq<Self>`]eq(). rust-analyzer cargo rrule 0.14.0 core/rrule/impl#[Frequency][`PartialEq<Self>`]eq().Frequencyrust-analyzer cargo rrule 0.14.0 core/rrule/Frequency#::Yearlyrust-analyzer cargo rrule 0.14.0 core/rrule/Frequency#Yearly#; |
| 200 | if !rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/bit/impl#[bool][Not]not().valid { |
| 201 | return Errrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#Err#(ValidationErrorrust-analyzer cargo rrule 0.14.0 validator/error/ValidationError#::InvalidByRuleAndFrequencyrust-analyzer cargo rrule 0.14.0 validator/error/ValidationError#InvalidByRuleAndFrequency# { |
| 202 | by_rulerust-analyzer cargo rrule 0.14.0 validator/error/ValidationError#InvalidByRuleAndFrequency#by_rule.: "BYWEEKNO".intorust-analyzer cargo core https://github.com/rust-lang/rust/library/core convert/impl#[T][`Into<U>`]into().(), |
| 203 | freqrust-analyzer cargo rrule 0.14.0 validator/error/ValidationError#InvalidByRuleAndFrequency#freq.: rrule.freqrust-analyzer cargo rrule 0.14.0 core/rrule/RRule#freq., |
| 204 | }); |
| 205 | } |
| 206 | } |
| 207 | Okrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#Ok#(()) |
| 208 | } |
| 209 | |
| 210 | // By_weekday: |
| 211 | // - Check if value for `Nth` is within range. |
| 212 | // The Range depends on frequency and can only happen weekly, so `/7` from normal count. |
| 213 | fn validate_by_weekdayrust-analyzer cargo rrule 0.14.0 validator/validate_rrule/validate_by_weekday().( |
| 214 | rrule: &RRulerust-analyzer cargo rrule 0.14.0 core/rrule/RRule#<Unvalidatedrust-analyzer cargo rrule 0.14.0 core/Unvalidated#>, |
| 215 | _dt_start: &chronorust-analyzer cargo chrono 0.4.40 crate/::DateTimerust-analyzer cargo chrono 0.4.40 datetime/DateTime#<Tzrust-analyzer cargo rrule 0.14.0 core/timezone/Tz#>, |
| 216 | ) -> Resultrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#<(), ValidationErrorrust-analyzer cargo rrule 0.14.0 validator/error/ValidationError#> { |
| 217 | let range = match rrule.freqrust-analyzer cargo rrule 0.14.0 core/rrule/RRule#freq. { |
| 218 | Frequencyrust-analyzer cargo rrule 0.14.0 core/rrule/Frequency#::Yearlyrust-analyzer cargo rrule 0.14.0 core/rrule/Frequency#Yearly# | Frequencyrust-analyzer cargo rrule 0.14.0 core/rrule/Frequency#::Dailyrust-analyzer cargo rrule 0.14.0 core/rrule/Frequency#Daily# => (-rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[i16][Neg]neg().366 rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[i16][`Div<Self>`]div()./rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[i16][`Div<Self>`]div(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[i16][`Div<Self>`]div().7)..=rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/range/RangeInclusive#(366 rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[i16][`Div<Self>`]div()./rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[i16][`Div<Self>`]div(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[i16][`Div<Self>`]div().7 rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[i16][`Add<Self>`]add().+rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[i16][`Add<Self>`]add(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[i16][`Add<Self>`]add().1), // TODO is the daily range correct? |
| 219 | Frequencyrust-analyzer cargo rrule 0.14.0 core/rrule/Frequency#::Monthlyrust-analyzer cargo rrule 0.14.0 core/rrule/Frequency#Monthly# => (-rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[i16][Neg]neg().31 rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[i16][`Div<Self>`]div()./rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[i16][`Div<Self>`]div(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[i16][`Div<Self>`]div().7)..=rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/range/RangeInclusive#(31 rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[i16][`Div<Self>`]div()./rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[i16][`Div<Self>`]div(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[i16][`Div<Self>`]div().7 rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[i16][`Add<Self>`]add().+rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[i16][`Add<Self>`]add(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[i16][`Add<Self>`]add().1), |
| 220 | Frequencyrust-analyzer cargo rrule 0.14.0 core/rrule/Frequency#::Weeklyrust-analyzer cargo rrule 0.14.0 core/rrule/Frequency#Weekly# => (-rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[i16][Neg]neg().53 rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[i16][`Div<Self>`]div()./rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[i16][`Div<Self>`]div(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[i16][`Div<Self>`]div().7)..=rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/range/RangeInclusive#(53 rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[i16][`Div<Self>`]div()./rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[i16][`Div<Self>`]div(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[i16][`Div<Self>`]div().7 rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[i16][`Add<Self>`]add().+rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[i16][`Add<Self>`]add(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[i16][`Add<Self>`]add().1), |
| 221 | Frequencyrust-analyzer cargo rrule 0.14.0 core/rrule/Frequency#::Hourlyrust-analyzer cargo rrule 0.14.0 core/rrule/Frequency#Hourly# => (-rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[i16][Neg]neg().24 rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[i16][`Div<Self>`]div()./rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[i16][`Div<Self>`]div(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[i16][`Div<Self>`]div().7)..=rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/range/RangeInclusive#(24 rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[i16][`Div<Self>`]div()./rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[i16][`Div<Self>`]div(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[i16][`Div<Self>`]div().7 rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[i16][`Add<Self>`]add().+rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[i16][`Add<Self>`]add(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[i16][`Add<Self>`]add().1), |
| 222 | Frequencyrust-analyzer cargo rrule 0.14.0 core/rrule/Frequency#::Minutelyrust-analyzer cargo rrule 0.14.0 core/rrule/Frequency#Minutely# | Frequencyrust-analyzer cargo rrule 0.14.0 core/rrule/Frequency#::Secondlyrust-analyzer cargo rrule 0.14.0 core/rrule/Frequency#Secondly# => (-rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[i16][Neg]neg().60 rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[i16][`Div<Self>`]div()./rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[i16][`Div<Self>`]div(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[i16][`Div<Self>`]div().7)..=rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/range/RangeInclusive#(60 rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[i16][`Div<Self>`]div()./rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[i16][`Div<Self>`]div(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[i16][`Div<Self>`]div().7 rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[i16][`Add<Self>`]add().+rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[i16][`Add<Self>`]add(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[i16][`Add<Self>`]add().1), |
| 223 | }; |
| 224 | for item in &rrule.by_weekdayrust-analyzer cargo rrule 0.14.0 core/rrule/RRule#by_weekday. { |
| 225 | if let NWeekdayrust-analyzer cargo rrule 0.14.0 core/rrule/NWeekday#::Nthrust-analyzer cargo rrule 0.14.0 core/rrule/NWeekday#Nth#(number, _weekday) = item { |
| 226 | // If value not in range = error |
| 227 | if !rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/bit/impl#[bool][Not]not().range.containsrust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/range/impl#[`RangeInclusive<Idx>`]contains().(number) { |
| 228 | return Errrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#Err#(ValidationErrorrust-analyzer cargo rrule 0.14.0 validator/error/ValidationError#::InvalidFieldValueRangeWithFreqrust-analyzer cargo rrule 0.14.0 validator/error/ValidationError#InvalidFieldValueRangeWithFreq# { |
| 229 | fieldrust-analyzer cargo rrule 0.14.0 validator/error/ValidationError#InvalidFieldValueRangeWithFreq#field.: "BYDAY".intorust-analyzer cargo core https://github.com/rust-lang/rust/library/core convert/impl#[T][`Into<U>`]into().(), |
| 230 | valuerust-analyzer cargo rrule 0.14.0 validator/error/ValidationError#InvalidFieldValueRangeWithFreq#value.: number.to_stringrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/impl#[T][ToString]to_string().(), |
| 231 | freqrust-analyzer cargo rrule 0.14.0 validator/error/ValidationError#InvalidFieldValueRangeWithFreq#freq.: rrule.freqrust-analyzer cargo rrule 0.14.0 core/rrule/RRule#freq., |
| 232 | start_idxrust-analyzer cargo rrule 0.14.0 validator/error/ValidationError#InvalidFieldValueRangeWithFreq#start_idx.: range.startrust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/range/impl#[`RangeInclusive<Idx>`]start().().to_stringrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/impl#[T][ToString]to_string().(), |
| 233 | end_idxrust-analyzer cargo rrule 0.14.0 validator/error/ValidationError#InvalidFieldValueRangeWithFreq#end_idx.: range.endrust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/range/impl#[`RangeInclusive<Idx>`]end().().to_stringrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/impl#[T][ToString]to_string().(), |
| 234 | }); |
| 235 | } |
| 236 | } |
| 237 | } |
| 238 | Okrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#Ok#(()) |
| 239 | } |
| 240 | |
| 241 | // By_hour: |
| 242 | // - Can be a value from 0 to 23. |
| 243 | fn validate_by_hourrust-analyzer cargo rrule 0.14.0 validator/validate_rrule/validate_by_hour().( |
| 244 | rrule: &RRulerust-analyzer cargo rrule 0.14.0 core/rrule/RRule#<Unvalidatedrust-analyzer cargo rrule 0.14.0 core/Unvalidated#>, |
| 245 | _dt_start: &chronorust-analyzer cargo chrono 0.4.40 crate/::DateTimerust-analyzer cargo chrono 0.4.40 datetime/DateTime#<Tzrust-analyzer cargo rrule 0.14.0 core/timezone/Tz#>, |
| 246 | ) -> Resultrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#<(), ValidationErrorrust-analyzer cargo rrule 0.14.0 validator/error/ValidationError#> { |
| 247 | validate_range_for_vecrust-analyzer cargo rrule 0.14.0 validator/validate_rrule/validate_range_for_vec().(&(0..=rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/range/RangeInclusive#23), &rrule.by_hourrust-analyzer cargo rrule 0.14.0 core/rrule/RRule#by_hour., "BYHOUR") |
| 248 | } |
| 249 | |
| 250 | // By_minute: |
| 251 | // - Can be a value from 0 to 59. |
| 252 | fn validate_by_minuterust-analyzer cargo rrule 0.14.0 validator/validate_rrule/validate_by_minute().( |
| 253 | rrule: &RRulerust-analyzer cargo rrule 0.14.0 core/rrule/RRule#<Unvalidatedrust-analyzer cargo rrule 0.14.0 core/Unvalidated#>, |
| 254 | _dt_start: &chronorust-analyzer cargo chrono 0.4.40 crate/::DateTimerust-analyzer cargo chrono 0.4.40 datetime/DateTime#<Tzrust-analyzer cargo rrule 0.14.0 core/timezone/Tz#>, |
| 255 | ) -> Resultrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#<(), ValidationErrorrust-analyzer cargo rrule 0.14.0 validator/error/ValidationError#> { |
| 256 | validate_range_for_vecrust-analyzer cargo rrule 0.14.0 validator/validate_rrule/validate_range_for_vec().(&(0..=rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/range/RangeInclusive#59), &rrule.by_minuterust-analyzer cargo rrule 0.14.0 core/rrule/RRule#by_minute., "BYMINUTE") |
| 257 | } |
| 258 | |
| 259 | // By_second: |
| 260 | // - Can be a value from 0 to 59. |
| 261 | fn validate_by_secondrust-analyzer cargo rrule 0.14.0 validator/validate_rrule/validate_by_second().( |
| 262 | rrule: &RRulerust-analyzer cargo rrule 0.14.0 core/rrule/RRule#<Unvalidatedrust-analyzer cargo rrule 0.14.0 core/Unvalidated#>, |
| 263 | _dt_start: &chronorust-analyzer cargo chrono 0.4.40 crate/::DateTimerust-analyzer cargo chrono 0.4.40 datetime/DateTime#<Tzrust-analyzer cargo rrule 0.14.0 core/timezone/Tz#>, |
| 264 | ) -> Resultrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#<(), ValidationErrorrust-analyzer cargo rrule 0.14.0 validator/error/ValidationError#> { |
| 265 | validate_range_for_vecrust-analyzer cargo rrule 0.14.0 validator/validate_rrule/validate_range_for_vec().(&(0..=rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/range/RangeInclusive#59), &rrule.by_secondrust-analyzer cargo rrule 0.14.0 core/rrule/RRule#by_second., "BYSECOND") |
| 266 | } |
| 267 | |
| 268 | fn validate_by_easterrust-analyzer cargo rrule 0.14.0 validator/validate_rrule/validate_by_easter().( |
| 269 | rrule: &RRulerust-analyzer cargo rrule 0.14.0 core/rrule/RRule#<Unvalidatedrust-analyzer cargo rrule 0.14.0 core/Unvalidated#>, |
| 270 | _dt_start: &chronorust-analyzer cargo chrono 0.4.40 crate/::DateTimerust-analyzer cargo chrono 0.4.40 datetime/DateTime#<Tzrust-analyzer cargo rrule 0.14.0 core/timezone/Tz#>, |
| 271 | ) -> Resultrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#<(), ValidationErrorrust-analyzer cargo rrule 0.14.0 validator/error/ValidationError#> { |
| 272 | #[cfg(feature = "by-easter")] |
| 273 | { |
| 274 | // By_easter: |
| 275 | // - Can be a value from -366 to 366. |
| 276 | // Validated below |
| 277 | if let Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#(by_easter) = &rrule.by_easterrust-analyzer cargo rrule 0.14.0 core/rrule/RRule#by_easter. { |
| 278 | validate_range_for_vecrust-analyzer cargo rrule 0.14.0 validator/validate_rrule/validate_range_for_vec().(&(-rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[i16][Neg]neg().366..=rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/range/RangeInclusive#366), &[*rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/deref/impl#[`&T`][Deref]deref().by_easter], "BYEASTER")?rust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`][Try]branch().; |
| 279 | } |
| 280 | // - Can only be used on frequency: Yearly, Monthly, Daily |
| 281 | // Validated below |
| 282 | if rrule.by_easterrust-analyzer cargo rrule 0.14.0 core/rrule/RRule#by_easter..is_somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/impl#[`Option<T>`]is_some().() { |
| 283 | let valid = matchesrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/matches!!( |
| 284 | rrule.freqrust-analyzer cargo rrule 0.14.0 core/rrule/RRule#freq., |
| 285 | Frequencyrust-analyzer cargo rrule 0.14.0 core/rrule/Frequency#::Yearlyrust-analyzer cargo rrule 0.14.0 core/rrule/Frequency#Yearly# | Frequencyrust-analyzer cargo rrule 0.14.0 core/rrule/Frequency#::Monthlyrust-analyzer cargo rrule 0.14.0 core/rrule/Frequency#Monthly# | Frequencyrust-analyzer cargo rrule 0.14.0 core/rrule/Frequency#::Dailyrust-analyzer cargo rrule 0.14.0 core/rrule/Frequency#Daily# |
| 286 | ); |
| 287 | if !rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/bit/impl#[bool][Not]not().valid { |
| 288 | return Errrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#Err#(ValidationErrorrust-analyzer cargo rrule 0.14.0 validator/error/ValidationError#::InvalidByRuleAndFrequencyrust-analyzer cargo rrule 0.14.0 validator/error/ValidationError#InvalidByRuleAndFrequency# { |
| 289 | by_rulerust-analyzer cargo rrule 0.14.0 validator/error/ValidationError#InvalidByRuleAndFrequency#by_rule.: "BYEASTER".intorust-analyzer cargo core https://github.com/rust-lang/rust/library/core convert/impl#[T][`Into<U>`]into().(), |
| 290 | freqrust-analyzer cargo rrule 0.14.0 validator/error/ValidationError#InvalidByRuleAndFrequency#freq.: rrule.freqrust-analyzer cargo rrule 0.14.0 core/rrule/RRule#freq., |
| 291 | }); |
| 292 | } |
| 293 | } |
| 294 | // - Can only be used when `by_hour`, `by_minute` and `by_second` are used. |
| 295 | // TODO don't know why this is true, but seems to loop forever otherwise. |
| 296 | if rrule.by_easterrust-analyzer cargo rrule 0.14.0 core/rrule/RRule#by_easter..is_somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/impl#[`Option<T>`]is_some().() |
| 297 | && (rrule.by_hourrust-analyzer cargo rrule 0.14.0 core/rrule/RRule#by_hour..is_emptyrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/impl#[`Vec<T, A>`]is_empty().() |
| 298 | || rrule.by_minuterust-analyzer cargo rrule 0.14.0 core/rrule/RRule#by_minute..is_emptyrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/impl#[`Vec<T, A>`]is_empty().() |
| 299 | || rrule.by_secondrust-analyzer cargo rrule 0.14.0 core/rrule/RRule#by_second..is_emptyrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/impl#[`Vec<T, A>`]is_empty().()) |
| 300 | { |
| 301 | return Errrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#Err#(ValidationErrorrust-analyzer cargo rrule 0.14.0 validator/error/ValidationError#::InvalidByRuleWithByEasterrust-analyzer cargo rrule 0.14.0 validator/error/ValidationError#InvalidByRuleWithByEaster#); |
| 302 | } |
| 303 | } |
| 304 | #[cfg(not(feature = "by-easter"))] |
| 305 | { |
| 306 | if rrule.by_easter.is_some() { |
| 307 | logrust-analyzer cargo log 0.4.27 crate/::warnrust-analyzer cargo log 0.4.27 macros/warn!!( |
| 308 | "The `by-easter` feature flag is not set, but `by_easter` is used.\ |
| 309 | The `by_easter` will be ignored, as if it was set to `None`." |
| 310 | ); |
| 311 | } |
| 312 | } |
| 313 | Okrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#Ok#(()) |
| 314 | } |
| 315 | |
| 316 | fn validate_range_for_vec_errorrust-analyzer cargo rrule 0.14.0 validator/validate_rrule/validate_range_for_vec_error().<'a, T: PartialOrdrust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/PartialOrd#>( |
| 317 | range: &RangeInclusiverust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/range/RangeInclusive#<T>, |
| 318 | list: &'a [T], |
| 319 | ) -> Resultrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#<(), &'a T> { |
| 320 | for item in list { |
| 321 | // If value not in range = error |
| 322 | if !rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/bit/impl#[bool][Not]not().range.containsrust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/range/impl#[`RangeInclusive<Idx>`]contains().(item) { |
| 323 | return Errrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#Err#(item); |
| 324 | } |
| 325 | } |
| 326 | Okrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#Ok#(()) |
| 327 | } |
| 328 | |
| 329 | fn validate_range_for_vecrust-analyzer cargo rrule 0.14.0 validator/validate_rrule/validate_range_for_vec().<T: PartialOrdrust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/PartialOrd# + ToStringrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/ToString#>( |
| 330 | range: &RangeInclusiverust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/range/RangeInclusive#<T>, |
| 331 | list: &[T], |
| 332 | field: &str, |
| 333 | ) -> Resultrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#<(), ValidationErrorrust-analyzer cargo rrule 0.14.0 validator/error/ValidationError#> { |
| 334 | for item in list { |
| 335 | // If value not in range = error |
| 336 | if !rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/bit/impl#[bool][Not]not().range.containsrust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/range/impl#[`RangeInclusive<Idx>`]contains().(item) { |
| 337 | return Errrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#Err#(ValidationErrorrust-analyzer cargo rrule 0.14.0 validator/error/ValidationError#::InvalidFieldValueRangerust-analyzer cargo rrule 0.14.0 validator/error/ValidationError#InvalidFieldValueRange# { |
| 338 | fieldrust-analyzer cargo rrule 0.14.0 validator/error/ValidationError#InvalidFieldValueRange#field.: field.to_stringrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/impl#[T][ToString]to_string().(), |
| 339 | valuerust-analyzer cargo rrule 0.14.0 validator/error/ValidationError#InvalidFieldValueRange#value.: item.to_stringrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/ToString#to_string().(), |
| 340 | start_idxrust-analyzer cargo rrule 0.14.0 validator/error/ValidationError#InvalidFieldValueRange#start_idx.: range.startrust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/range/impl#[`RangeInclusive<Idx>`]start().().to_stringrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/ToString#to_string().(), |
| 341 | end_idxrust-analyzer cargo rrule 0.14.0 validator/error/ValidationError#InvalidFieldValueRange#end_idx.: range.endrust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/range/impl#[`RangeInclusive<Idx>`]end().().to_stringrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/ToString#to_string().(), |
| 342 | }); |
| 343 | } |
| 344 | } |
| 345 | Okrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#Ok#(()) |
| 346 | } |
| 347 | |
| 348 | fn validate_not_equal_for_vecrust-analyzer cargo rrule 0.14.0 validator/validate_rrule/validate_not_equal_for_vec().<T: PartialEqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/PartialEq#<T> + ToStringrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/ToString#>( |
| 349 | value: &T, |
| 350 | list: &[T], |
| 351 | field: &str, |
| 352 | ) -> Resultrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#<(), ValidationErrorrust-analyzer cargo rrule 0.14.0 validator/error/ValidationError#> { |
| 353 | if list.iterrust-analyzer cargo core https://github.com/rust-lang/rust/library/core slice/impl#[`[T]`]iter().().anyrust-analyzer cargo core https://github.com/rust-lang/rust/library/core slice/iter/impl#[`Iter<'a, T>`][Iterator]any().(|item| item rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[`&A`][`PartialEq<&B>`]eq().==rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[`&A`][`PartialEq<&B>`]eq(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[`&A`][`PartialEq<&B>`]eq().value) { |
| 354 | return Errrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#Err#(ValidationErrorrust-analyzer cargo rrule 0.14.0 validator/error/ValidationError#::InvalidFieldValuerust-analyzer cargo rrule 0.14.0 validator/error/ValidationError#InvalidFieldValue# { |
| 355 | fieldrust-analyzer cargo rrule 0.14.0 validator/error/ValidationError#InvalidFieldValue#field.: field.to_stringrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/impl#[T][ToString]to_string().(), |
| 356 | valuerust-analyzer cargo rrule 0.14.0 validator/error/ValidationError#InvalidFieldValue#value.: value.to_stringrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/ToString#to_string().(), |
| 357 | }); |
| 358 | } |
| 359 | Okrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#Ok#(()) |
| 360 | } |
| 361 | |
| 362 | #[cfg(test)] |
| 363 | mod testsrust-analyzer cargo rrule 0.14.0 validator/validate_rrule/tests/ { |
| 364 | use chronorust-analyzer cargo chrono 0.4.40 crate/::TimeZonerust-analyzer cargo chrono 0.4.40 offset/TimeZone#; |
| 365 | |
| 366 | 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#; |
| 367 | |
| 368 | use superrust-analyzer cargo rrule 0.14.0 validator/validate_rrule/::*; |
| 369 | |
| 370 | const UTCrust-analyzer cargo rrule 0.14.0 validator/validate_rrule/tests/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.; |
| 371 | |
| 372 | #[testrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/test:] |
| 373 | fn rejects_by_set_pos_without_byxxx_rulerust-analyzer cargo rrule 0.14.0 validator/validate_rrule/tests/rejects_by_set_pos_without_byxxx_rule().() { |
| 374 | let rrule = RRulerust-analyzer cargo rrule 0.14.0 core/rrule/RRule# { |
| 375 | by_set_posrust-analyzer cargo rrule 0.14.0 core/rrule/RRule#by_set_pos.: vecrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc macros/vec!![-rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[i32][Neg]neg().1], |
| 376 | ..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().() |
| 377 | }; |
| 378 | let dt_start = UTCrust-analyzer cargo rrule 0.14.0 validator/validate_rrule/tests/UTC..with_ymd_and_hmsrust-analyzer cargo chrono 0.4.40 offset/TimeZone#with_ymd_and_hms().(1970, 1, 1, 0, 0, 0).unwraprust-analyzer cargo chrono 0.4.40 offset/impl#[`LocalResult<T>`]unwrap().(); |
| 379 | let res = validate_rrule_forcedrust-analyzer cargo rrule 0.14.0 validator/validate_rrule/validate_rrule_forced().(&rrule, &dt_start); |
| 380 | assertrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/assert!!(res.is_errrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]is_err().()); |
| 381 | let err = res.unwrap_errrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]unwrap_err().(); |
| 382 | assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(err, ValidationErrorrust-analyzer cargo rrule 0.14.0 validator/error/ValidationError#::BySetPosWithoutByRulerust-analyzer cargo rrule 0.14.0 validator/error/ValidationError#BySetPosWithoutByRule#); |
| 383 | |
| 384 | // When creating RRule directly, |
| 385 | // if `rrule.by_set_hour` is empty, then it is going to default to |
| 386 | // `dt_start.hour()`, therefore, there is always a BYXXX |
| 387 | // rule, and the rrule is accepted. |
| 388 | let res = rrule.buildrust-analyzer cargo rrule 0.14.0 core/rrule/impl#[`RRule<Unvalidated>`]build().(dt_start); |
| 389 | 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().()); |
| 390 | } |
| 391 | |
| 392 | #[testrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/test:] |
| 393 | fn rejects_by_rule_field_with_invalid_valuerust-analyzer cargo rrule 0.14.0 validator/validate_rrule/tests/rejects_by_rule_field_with_invalid_value().() { |
| 394 | let tests = [ |
| 395 | ( |
| 396 | "BYSETPOS", |
| 397 | RRulerust-analyzer cargo rrule 0.14.0 core/rrule/RRule# { |
| 398 | by_set_posrust-analyzer cargo rrule 0.14.0 core/rrule/RRule#by_set_pos.: vecrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc macros/vec!![0], |
| 399 | ..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().() |
| 400 | }, |
| 401 | ), |
| 402 | ( |
| 403 | "BYSETPOS", |
| 404 | RRulerust-analyzer cargo rrule 0.14.0 core/rrule/RRule# { |
| 405 | by_set_posrust-analyzer cargo rrule 0.14.0 core/rrule/RRule#by_set_pos.: vecrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc macros/vec!![1, -rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[i32][Neg]neg().2, 0], |
| 406 | ..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().() |
| 407 | }, |
| 408 | ), |
| 409 | ( |
| 410 | "BYMONTHDAY", |
| 411 | RRulerust-analyzer cargo rrule 0.14.0 core/rrule/RRule# { |
| 412 | by_month_dayrust-analyzer cargo rrule 0.14.0 core/rrule/RRule#by_month_day.: vecrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc macros/vec!![0], |
| 413 | ..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().() |
| 414 | }, |
| 415 | ), |
| 416 | ( |
| 417 | "BYYEARDAY", |
| 418 | RRulerust-analyzer cargo rrule 0.14.0 core/rrule/RRule# { |
| 419 | by_year_dayrust-analyzer cargo rrule 0.14.0 core/rrule/RRule#by_year_day.: vecrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc macros/vec!![0], |
| 420 | ..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().() |
| 421 | }, |
| 422 | ), |
| 423 | ]; |
| 424 | for (field, rrule) in tests { |
| 425 | let res = |
| 426 | validate_rrule_forcedrust-analyzer cargo rrule 0.14.0 validator/validate_rrule/validate_rrule_forced().(&rrule, &UTCrust-analyzer cargo rrule 0.14.0 validator/validate_rrule/tests/UTC..with_ymd_and_hmsrust-analyzer cargo chrono 0.4.40 offset/TimeZone#with_ymd_and_hms().(1970, 1, 1, 0, 0, 0).unwraprust-analyzer cargo chrono 0.4.40 offset/impl#[`LocalResult<T>`]unwrap().()); |
| 427 | assertrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/assert!!(res.is_errrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]is_err().()); |
| 428 | let err = res.unwrap_errrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]unwrap_err().(); |
| 429 | assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!( |
| 430 | err, |
| 431 | ValidationErrorrust-analyzer cargo rrule 0.14.0 validator/error/ValidationError#::InvalidFieldValuerust-analyzer cargo rrule 0.14.0 validator/error/ValidationError#InvalidFieldValue# { |
| 432 | fieldrust-analyzer cargo rrule 0.14.0 validator/error/ValidationError#InvalidFieldValue#field.: field.intorust-analyzer cargo core https://github.com/rust-lang/rust/library/core convert/impl#[T][`Into<U>`]into().(), |
| 433 | valuerust-analyzer cargo rrule 0.14.0 validator/error/ValidationError#InvalidFieldValue#value.: "0".intorust-analyzer cargo core https://github.com/rust-lang/rust/library/core convert/impl#[T][`Into<U>`]into().() |
| 434 | } |
| 435 | ); |
| 436 | } |
| 437 | } |
| 438 | |
| 439 | #[testrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/test:] |
| 440 | fn rejects_by_rule_field_with_value_outside_allowed_rangerust-analyzer cargo rrule 0.14.0 validator/validate_rrule/tests/rejects_by_rule_field_with_value_outside_allowed_range().() { |
| 441 | let tests = [ |
| 442 | ( |
| 443 | "BYMONTHDAY", |
| 444 | RRulerust-analyzer cargo rrule 0.14.0 core/rrule/RRule# { |
| 445 | by_month_dayrust-analyzer cargo rrule 0.14.0 core/rrule/RRule#by_month_day.: vecrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc macros/vec!![34], |
| 446 | ..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().() |
| 447 | }, |
| 448 | "34", |
| 449 | "-31", |
| 450 | "31", |
| 451 | ), |
| 452 | ( |
| 453 | "BYYEARDAY", |
| 454 | RRulerust-analyzer cargo rrule 0.14.0 core/rrule/RRule# { |
| 455 | by_year_dayrust-analyzer cargo rrule 0.14.0 core/rrule/RRule#by_year_day.: vecrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc macros/vec!![17, 400], |
| 456 | ..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().() |
| 457 | }, |
| 458 | "400", |
| 459 | "-366", |
| 460 | "366", |
| 461 | ), |
| 462 | ]; |
| 463 | for (field, rrule, value, start_idx, end_idx) in tests { |
| 464 | let res = |
| 465 | validate_rrule_forcedrust-analyzer cargo rrule 0.14.0 validator/validate_rrule/validate_rrule_forced().(&rrule, &UTCrust-analyzer cargo rrule 0.14.0 validator/validate_rrule/tests/UTC..with_ymd_and_hmsrust-analyzer cargo chrono 0.4.40 offset/TimeZone#with_ymd_and_hms().(1970, 1, 1, 0, 0, 0).unwraprust-analyzer cargo chrono 0.4.40 offset/impl#[`LocalResult<T>`]unwrap().()); |
| 466 | assertrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/assert!!(res.is_errrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]is_err().()); |
| 467 | let err = res.unwrap_errrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]unwrap_err().(); |
| 468 | assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!( |
| 469 | err, |
| 470 | ValidationErrorrust-analyzer cargo rrule 0.14.0 validator/error/ValidationError#::InvalidFieldValueRangerust-analyzer cargo rrule 0.14.0 validator/error/ValidationError#InvalidFieldValueRange# { |
| 471 | fieldrust-analyzer cargo rrule 0.14.0 validator/error/ValidationError#InvalidFieldValueRange#field.: field.intorust-analyzer cargo core https://github.com/rust-lang/rust/library/core convert/impl#[T][`Into<U>`]into().(), |
| 472 | valuerust-analyzer cargo rrule 0.14.0 validator/error/ValidationError#InvalidFieldValueRange#value.: value.intorust-analyzer cargo core https://github.com/rust-lang/rust/library/core convert/impl#[T][`Into<U>`]into().(), |
| 473 | start_idxrust-analyzer cargo rrule 0.14.0 validator/error/ValidationError#InvalidFieldValueRange#start_idx.: start_idx.intorust-analyzer cargo core https://github.com/rust-lang/rust/library/core convert/impl#[T][`Into<U>`]into().(), |
| 474 | end_idxrust-analyzer cargo rrule 0.14.0 validator/error/ValidationError#InvalidFieldValueRange#end_idx.: end_idx.intorust-analyzer cargo core https://github.com/rust-lang/rust/library/core convert/impl#[T][`Into<U>`]into().() |
| 475 | } |
| 476 | ); |
| 477 | } |
| 478 | } |
| 479 | |
| 480 | #[testrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/test:] |
| 481 | fn rejects_by_rule_value_outside_allowed_freq_rangerust-analyzer cargo rrule 0.14.0 validator/validate_rrule/tests/rejects_by_rule_value_outside_allowed_freq_range().() { |
| 482 | let tests = [ |
| 483 | ( |
| 484 | "BYSETPOS", |
| 485 | RRulerust-analyzer cargo rrule 0.14.0 core/rrule/RRule# { |
| 486 | freqrust-analyzer cargo rrule 0.14.0 core/rrule/RRule#freq.: Frequencyrust-analyzer cargo rrule 0.14.0 core/rrule/Frequency#::Hourlyrust-analyzer cargo rrule 0.14.0 core/rrule/Frequency#Hourly#, |
| 487 | by_set_posrust-analyzer cargo rrule 0.14.0 core/rrule/RRule#by_set_pos.: vecrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc macros/vec!![30], |
| 488 | ..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().() |
| 489 | }, |
| 490 | "30", |
| 491 | "-24", |
| 492 | "24", |
| 493 | ), |
| 494 | ( |
| 495 | "BYSETPOS", |
| 496 | RRulerust-analyzer cargo rrule 0.14.0 core/rrule/RRule# { |
| 497 | 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#, |
| 498 | by_set_posrust-analyzer cargo rrule 0.14.0 core/rrule/RRule#by_set_pos.: vecrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc macros/vec!![400], |
| 499 | ..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().() |
| 500 | }, |
| 501 | "400", |
| 502 | "-366", |
| 503 | "366", |
| 504 | ), |
| 505 | ]; |
| 506 | for (field, rrule, value, start_idx, end_idx) in tests { |
| 507 | let res = |
| 508 | validate_rrule_forcedrust-analyzer cargo rrule 0.14.0 validator/validate_rrule/validate_rrule_forced().(&rrule, &UTCrust-analyzer cargo rrule 0.14.0 validator/validate_rrule/tests/UTC..with_ymd_and_hmsrust-analyzer cargo chrono 0.4.40 offset/TimeZone#with_ymd_and_hms().(1970, 1, 1, 0, 0, 0).unwraprust-analyzer cargo chrono 0.4.40 offset/impl#[`LocalResult<T>`]unwrap().()); |
| 509 | assertrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/assert!!(res.is_errrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]is_err().()); |
| 510 | let err = res.unwrap_errrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]unwrap_err().(); |
| 511 | assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!( |
| 512 | err, |
| 513 | ValidationErrorrust-analyzer cargo rrule 0.14.0 validator/error/ValidationError#::InvalidFieldValueRangeWithFreqrust-analyzer cargo rrule 0.14.0 validator/error/ValidationError#InvalidFieldValueRangeWithFreq# { |
| 514 | fieldrust-analyzer cargo rrule 0.14.0 validator/error/ValidationError#InvalidFieldValueRangeWithFreq#field.: field.intorust-analyzer cargo core https://github.com/rust-lang/rust/library/core convert/impl#[T][`Into<U>`]into().(), |
| 515 | freqrust-analyzer cargo rrule 0.14.0 validator/error/ValidationError#InvalidFieldValueRangeWithFreq#freq.: rrule.freqrust-analyzer cargo rrule 0.14.0 core/rrule/RRule#freq., |
| 516 | valuerust-analyzer cargo rrule 0.14.0 validator/error/ValidationError#InvalidFieldValueRangeWithFreq#value.: value.intorust-analyzer cargo core https://github.com/rust-lang/rust/library/core convert/impl#[T][`Into<U>`]into().(), |
| 517 | start_idxrust-analyzer cargo rrule 0.14.0 validator/error/ValidationError#InvalidFieldValueRangeWithFreq#start_idx.: start_idx.intorust-analyzer cargo core https://github.com/rust-lang/rust/library/core convert/impl#[T][`Into<U>`]into().(), |
| 518 | end_idxrust-analyzer cargo rrule 0.14.0 validator/error/ValidationError#InvalidFieldValueRangeWithFreq#end_idx.: end_idx.intorust-analyzer cargo core https://github.com/rust-lang/rust/library/core convert/impl#[T][`Into<U>`]into().(), |
| 519 | } |
| 520 | ); |
| 521 | } |
| 522 | } |
| 523 | |
| 524 | #[testrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/test:] |
| 525 | fn rejects_invalid_by_rule_and_freq_combosrust-analyzer cargo rrule 0.14.0 validator/validate_rrule/tests/rejects_invalid_by_rule_and_freq_combos().() { |
| 526 | let tests = [ |
| 527 | ( |
| 528 | "BYMONTHDAY", |
| 529 | RRulerust-analyzer cargo rrule 0.14.0 core/rrule/RRule# { |
| 530 | 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#, |
| 531 | by_month_dayrust-analyzer cargo rrule 0.14.0 core/rrule/RRule#by_month_day.: vecrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc macros/vec!![-rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[i8][Neg]neg().1], |
| 532 | ..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().() |
| 533 | }, |
| 534 | ), |
| 535 | ( |
| 536 | "BYYEARDAY", |
| 537 | RRulerust-analyzer cargo rrule 0.14.0 core/rrule/RRule# { |
| 538 | freqrust-analyzer cargo rrule 0.14.0 core/rrule/RRule#freq.: Frequencyrust-analyzer cargo rrule 0.14.0 core/rrule/Frequency#::Monthlyrust-analyzer cargo rrule 0.14.0 core/rrule/Frequency#Monthly#, |
| 539 | by_year_dayrust-analyzer cargo rrule 0.14.0 core/rrule/RRule#by_year_day.: vecrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc macros/vec!![120], |
| 540 | ..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().() |
| 541 | }, |
| 542 | ), |
| 543 | ( |
| 544 | "BYYEARDAY", |
| 545 | RRulerust-analyzer cargo rrule 0.14.0 core/rrule/RRule# { |
| 546 | 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#, |
| 547 | by_year_dayrust-analyzer cargo rrule 0.14.0 core/rrule/RRule#by_year_day.: vecrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc macros/vec!![120], |
| 548 | ..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().() |
| 549 | }, |
| 550 | ), |
| 551 | ( |
| 552 | "BYYEARDAY", |
| 553 | RRulerust-analyzer cargo rrule 0.14.0 core/rrule/RRule# { |
| 554 | 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#, |
| 555 | by_year_dayrust-analyzer cargo rrule 0.14.0 core/rrule/RRule#by_year_day.: vecrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc macros/vec!![120], |
| 556 | ..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().() |
| 557 | }, |
| 558 | ), |
| 559 | ]; |
| 560 | for (field, rrule) in tests { |
| 561 | let res = |
| 562 | validate_rrule_forcedrust-analyzer cargo rrule 0.14.0 validator/validate_rrule/validate_rrule_forced().(&rrule, &UTCrust-analyzer cargo rrule 0.14.0 validator/validate_rrule/tests/UTC..with_ymd_and_hmsrust-analyzer cargo chrono 0.4.40 offset/TimeZone#with_ymd_and_hms().(1970, 1, 1, 0, 0, 0).unwraprust-analyzer cargo chrono 0.4.40 offset/impl#[`LocalResult<T>`]unwrap().()); |
| 563 | assertrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/assert!!(res.is_errrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]is_err().()); |
| 564 | let err = res.unwrap_errrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]unwrap_err().(); |
| 565 | assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!( |
| 566 | err, |
| 567 | ValidationErrorrust-analyzer cargo rrule 0.14.0 validator/error/ValidationError#::InvalidByRuleAndFrequencyrust-analyzer cargo rrule 0.14.0 validator/error/ValidationError#InvalidByRuleAndFrequency# { |
| 568 | by_rulerust-analyzer cargo rrule 0.14.0 validator/error/ValidationError#InvalidByRuleAndFrequency#by_rule.: field.intorust-analyzer cargo core https://github.com/rust-lang/rust/library/core convert/impl#[T][`Into<U>`]into().(), |
| 569 | freqrust-analyzer cargo rrule 0.14.0 validator/error/ValidationError#InvalidByRuleAndFrequency#freq.: rrule.freqrust-analyzer cargo rrule 0.14.0 core/rrule/RRule#freq. |
| 570 | } |
| 571 | ); |
| 572 | } |
| 573 | } |
| 574 | |
| 575 | #[testrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/test:] |
| 576 | fn rejects_start_date_after_untilrust-analyzer cargo rrule 0.14.0 validator/validate_rrule/tests/rejects_start_date_after_until().() { |
| 577 | let rrule = RRulerust-analyzer cargo rrule 0.14.0 core/rrule/RRule# { |
| 578 | 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 validator/validate_rrule/tests/UTC..with_ymd_and_hmsrust-analyzer cargo chrono 0.4.40 offset/TimeZone#with_ymd_and_hms().(2020, 1, 1, 0, 0, 0).unwraprust-analyzer cargo chrono 0.4.40 offset/impl#[`LocalResult<T>`]unwrap().()), |
| 579 | ..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().() |
| 580 | }; |
| 581 | let dt_start = UTCrust-analyzer cargo rrule 0.14.0 validator/validate_rrule/tests/UTC..with_ymd_and_hmsrust-analyzer cargo chrono 0.4.40 offset/TimeZone#with_ymd_and_hms().(2020, 1, 2, 0, 0, 0).unwraprust-analyzer cargo chrono 0.4.40 offset/impl#[`LocalResult<T>`]unwrap().(); |
| 582 | let res = validate_rrule_forcedrust-analyzer cargo rrule 0.14.0 validator/validate_rrule/validate_rrule_forced().(&rrule, &dt_start); |
| 583 | assertrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/assert!!(res.is_errrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]is_err().()); |
| 584 | let err = res.unwrap_errrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]unwrap_err().(); |
| 585 | assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!( |
| 586 | err, |
| 587 | ValidationErrorrust-analyzer cargo rrule 0.14.0 validator/error/ValidationError#::UntilBeforeStartrust-analyzer cargo rrule 0.14.0 validator/error/ValidationError#UntilBeforeStart# { |
| 588 | untilrust-analyzer cargo rrule 0.14.0 validator/error/ValidationError#UntilBeforeStart#until.: rrule.untilrust-analyzer cargo rrule 0.14.0 core/rrule/RRule#until..unwraprust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/impl#[`Option<T>`]unwrap().().to_rfc3339rust-analyzer cargo chrono 0.4.40 datetime/impl#[`DateTime<Tz>`]to_rfc3339().(), |
| 589 | dt_startrust-analyzer cargo rrule 0.14.0 validator/error/ValidationError#UntilBeforeStart#dt_start.: dt_start.to_rfc3339rust-analyzer cargo chrono 0.4.40 datetime/impl#[`DateTime<Tz>`]to_rfc3339().() |
| 590 | } |
| 591 | ); |
| 592 | } |
| 593 | |
| 594 | #[testrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/test:] |
| 595 | fn allows_until_with_compatible_timezonerust-analyzer cargo rrule 0.14.0 validator/validate_rrule/tests/allows_until_with_compatible_timezone().() { |
| 596 | fn trust-analyzer cargo rrule 0.14.0 validator/validate_rrule/tests/t().(start_tz: Tzrust-analyzer cargo rrule 0.14.0 core/timezone/Tz#, until_tz: Tzrust-analyzer cargo rrule 0.14.0 core/timezone/Tz#) -> (chronorust-analyzer cargo chrono 0.4.40 crate/::DateTimerust-analyzer cargo chrono 0.4.40 datetime/DateTime#<Tzrust-analyzer cargo rrule 0.14.0 core/timezone/Tz#>, chronorust-analyzer cargo chrono 0.4.40 crate/::DateTimerust-analyzer cargo chrono 0.4.40 datetime/DateTime#<Tzrust-analyzer cargo rrule 0.14.0 core/timezone/Tz#>) { |
| 597 | ( |
| 598 | start_tz.with_ymd_and_hmsrust-analyzer cargo chrono 0.4.40 offset/TimeZone#with_ymd_and_hms().(2020, 1, 1, 0, 0, 0).unwraprust-analyzer cargo chrono 0.4.40 offset/impl#[`LocalResult<T>`]unwrap().(), |
| 599 | until_tz.with_ymd_and_hmsrust-analyzer cargo chrono 0.4.40 offset/TimeZone#with_ymd_and_hms().(2020, 1, 1, 0, 0, 0).unwraprust-analyzer cargo chrono 0.4.40 offset/impl#[`LocalResult<T>`]unwrap().(), |
| 600 | ) |
| 601 | } |
| 602 | |
| 603 | let tests = [trust-analyzer cargo rrule 0.14.0 validator/validate_rrule/tests/t().(Tzrust-analyzer cargo rrule 0.14.0 core/timezone/Tz#::LOCALrust-analyzer cargo rrule 0.14.0 core/timezone/impl#[Tz]LOCAL., Tzrust-analyzer cargo rrule 0.14.0 core/timezone/Tz#::LOCALrust-analyzer cargo rrule 0.14.0 core/timezone/impl#[Tz]LOCAL.), trust-analyzer cargo rrule 0.14.0 validator/validate_rrule/tests/t().(Tzrust-analyzer cargo rrule 0.14.0 core/timezone/Tz#::LOCALrust-analyzer cargo rrule 0.14.0 core/timezone/impl#[Tz]LOCAL., UTCrust-analyzer cargo rrule 0.14.0 validator/validate_rrule/tests/UTC.), trust-analyzer cargo rrule 0.14.0 validator/validate_rrule/tests/t().(UTCrust-analyzer cargo rrule 0.14.0 validator/validate_rrule/tests/UTC., UTCrust-analyzer cargo rrule 0.14.0 validator/validate_rrule/tests/UTC.)]; |
| 604 | |
| 605 | for (start_date, until) in tests { |
| 606 | let rrule = RRulerust-analyzer cargo rrule 0.14.0 core/rrule/RRule# { |
| 607 | 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#(until), |
| 608 | ..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().() |
| 609 | }; |
| 610 | let res = validate_rrule_forcedrust-analyzer cargo rrule 0.14.0 validator/validate_rrule/validate_rrule_forced().(&rrule, &start_date); |
| 611 | 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().()); |
| 612 | } |
| 613 | } |
| 614 | |
| 615 | #[testrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/test:] |
| 616 | fn rejects_until_with_incompatible_timezonerust-analyzer cargo rrule 0.14.0 validator/validate_rrule/tests/rejects_until_with_incompatible_timezone().() { |
| 617 | fn trust-analyzer cargo rrule 0.14.0 validator/validate_rrule/tests/t().(start_tz: Tzrust-analyzer cargo rrule 0.14.0 core/timezone/Tz#, until_tz: Tzrust-analyzer cargo rrule 0.14.0 core/timezone/Tz#) -> (chronorust-analyzer cargo chrono 0.4.40 crate/::DateTimerust-analyzer cargo chrono 0.4.40 datetime/DateTime#<Tzrust-analyzer cargo rrule 0.14.0 core/timezone/Tz#>, chronorust-analyzer cargo chrono 0.4.40 crate/::DateTimerust-analyzer cargo chrono 0.4.40 datetime/DateTime#<Tzrust-analyzer cargo rrule 0.14.0 core/timezone/Tz#>) { |
| 618 | ( |
| 619 | start_tz.with_ymd_and_hmsrust-analyzer cargo chrono 0.4.40 offset/TimeZone#with_ymd_and_hms().(2020, 1, 1, 0, 0, 0).unwraprust-analyzer cargo chrono 0.4.40 offset/impl#[`LocalResult<T>`]unwrap().(), |
| 620 | until_tz.with_ymd_and_hmsrust-analyzer cargo chrono 0.4.40 offset/TimeZone#with_ymd_and_hms().(2020, 1, 1, 0, 0, 0).unwraprust-analyzer cargo chrono 0.4.40 offset/impl#[`LocalResult<T>`]unwrap().(), |
| 621 | ) |
| 622 | } |
| 623 | |
| 624 | let tests = [ |
| 625 | trust-analyzer cargo rrule 0.14.0 validator/validate_rrule/tests/t().(Tzrust-analyzer cargo rrule 0.14.0 core/timezone/Tz#::UTCrust-analyzer cargo rrule 0.14.0 core/timezone/impl#[Tz]UTC., Tzrust-analyzer cargo rrule 0.14.0 core/timezone/Tz#::LOCALrust-analyzer cargo rrule 0.14.0 core/timezone/impl#[Tz]LOCAL.), |
| 626 | trust-analyzer cargo rrule 0.14.0 validator/validate_rrule/tests/t().(Tzrust-analyzer cargo rrule 0.14.0 core/timezone/Tz#::Europe__Berlinrust-analyzer cargo rrule 0.14.0 core/timezone/impl#[Tz]Europe__Berlin., Tzrust-analyzer cargo rrule 0.14.0 core/timezone/Tz#::LOCALrust-analyzer cargo rrule 0.14.0 core/timezone/impl#[Tz]LOCAL.), |
| 627 | trust-analyzer cargo rrule 0.14.0 validator/validate_rrule/tests/t().(Tzrust-analyzer cargo rrule 0.14.0 core/timezone/Tz#::LOCALrust-analyzer cargo rrule 0.14.0 core/timezone/impl#[Tz]LOCAL., Tzrust-analyzer cargo rrule 0.14.0 core/timezone/Tz#::Europe__Berlinrust-analyzer cargo rrule 0.14.0 core/timezone/impl#[Tz]Europe__Berlin.), |
| 628 | ]; |
| 629 | |
| 630 | for (start_date, until) in tests { |
| 631 | let rrule = RRulerust-analyzer cargo rrule 0.14.0 core/rrule/RRule# { |
| 632 | 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#(until), |
| 633 | ..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().() |
| 634 | }; |
| 635 | let res = validate_rrule_forcedrust-analyzer cargo rrule 0.14.0 validator/validate_rrule/validate_rrule_forced().(&rrule, &start_date); |
| 636 | assertrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/assert!!(res.is_errrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]is_err().()); |
| 637 | let err = res.unwrap_errrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]unwrap_err().(); |
| 638 | assertrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/assert!!(matchesrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/matches!!( |
| 639 | err, |
| 640 | ValidationErrorrust-analyzer cargo rrule 0.14.0 validator/error/ValidationError#::DtStartUntilMismatchTimezonerust-analyzer cargo rrule 0.14.0 validator/error/ValidationError#DtStartUntilMismatchTimezone# { .. } |
| 641 | )); |
| 642 | } |
| 643 | } |
| 644 | } |