| 1 | use craterust-analyzer cargo jsonschema 0.37.4 crate/::{ |
| 2 | compilerrust-analyzer cargo jsonschema 0.37.4 compiler/, |
| 3 | errorrust-analyzer cargo jsonschema 0.37.4 error/::ValidationErrorrust-analyzer cargo jsonschema 0.37.4 error/ValidationError#, |
| 4 | extrust-analyzer cargo jsonschema 0.37.4 ext/::cmprust-analyzer cargo jsonschema 0.37.4 ext/cmp/, |
| 5 | keywordsrust-analyzer cargo jsonschema 0.37.4 keywords/::CompilationResultrust-analyzer cargo jsonschema 0.37.4 keywords/CompilationResult#, |
| 6 | pathsrust-analyzer cargo jsonschema 0.37.4 paths/::Locationrust-analyzer cargo jsonschema 0.37.4 paths/Location#, |
| 7 | validatorrust-analyzer cargo jsonschema 0.37.4 validator/::{Validaterust-analyzer cargo jsonschema 0.37.4 validator/Validate#, ValidationContextrust-analyzer cargo jsonschema 0.37.4 validator/ValidationContext#}, |
| 8 | }; |
| 9 | use serde_jsonrust-analyzer cargo serde_json 1.0.145 crate/::{Maprust-analyzer cargo serde_json 1.0.145 map/Map#, Numberrust-analyzer cargo serde_json 1.0.145 number/Number#, Valuerust-analyzer cargo serde_json 1.0.145 value/Value#}; |
| 10 | |
| 11 | use craterust-analyzer cargo jsonschema 0.37.4 crate/::pathsrust-analyzer cargo jsonschema 0.37.4 paths/::LazyLocationrust-analyzer cargo jsonschema 0.37.4 paths/LazyLocation#; |
| 12 | |
| 13 | struct ConstArrayValidatorrust-analyzer cargo jsonschema 0.37.4 keywords/const_/ConstArrayValidator# { |
| 14 | valuerust-analyzer cargo jsonschema 0.37.4 keywords/const_/ConstArrayValidator#value.: Vecrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/Vec#<Valuerust-analyzer cargo serde_json 1.0.145 value/Value#>, |
| 15 | locationrust-analyzer cargo jsonschema 0.37.4 keywords/const_/ConstArrayValidator#location.: Locationrust-analyzer cargo jsonschema 0.37.4 paths/Location#, |
| 16 | } |
| 17 | impl ConstArrayValidatorrust-analyzer cargo jsonschema 0.37.4 keywords/const_/ConstArrayValidator# { |
| 18 | #[inline] |
| 19 | pub(craterust-analyzer cargo jsonschema 0.37.4 crate/) fn compilerust-analyzer cargo jsonschema 0.37.4 keywords/const_/impl#[ConstArrayValidator]compile().(value: &[Valuerust-analyzer cargo serde_json 1.0.145 value/Value#], location: Locationrust-analyzer cargo jsonschema 0.37.4 paths/Location#) -> CompilationResultrust-analyzer cargo jsonschema 0.37.4 keywords/CompilationResult#<'_> { |
| 20 | Okrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#Ok#(Boxrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc boxed/Box#::newrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc boxed/impl#[`Box<T>`]new().(ConstArrayValidatorrust-analyzer cargo jsonschema 0.37.4 keywords/const_/ConstArrayValidator# { |
| 21 | valuerust-analyzer cargo jsonschema 0.37.4 keywords/const_/ConstArrayValidator#value.: value.to_vecrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc slice/impl#[`[T]`]to_vec().(), |
| 22 | locationrust-analyzer cargo jsonschema 0.37.4 keywords/const_/ConstArrayValidator#location., |
| 23 | })) |
| 24 | } |
| 25 | } |
| 26 | impl Validaterust-analyzer cargo jsonschema 0.37.4 validator/Validate# for ConstArrayValidatorrust-analyzer cargo jsonschema 0.37.4 keywords/const_/ConstArrayValidator# { |
| 27 | fn validaterust-analyzer cargo jsonschema 0.37.4 keywords/const_/impl#[ConstArrayValidator][Validate]validate().<'i>( |
| 28 | &self, |
| 29 | instance: &'i Valuerust-analyzer cargo serde_json 1.0.145 value/Value#, |
| 30 | location: &LazyLocationrust-analyzer cargo jsonschema 0.37.4 paths/LazyLocation#, |
| 31 | ctx: &mut ValidationContextrust-analyzer cargo jsonschema 0.37.4 validator/ValidationContext#, |
| 32 | ) -> Resultrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#<(), ValidationErrorrust-analyzer cargo jsonschema 0.37.4 error/ValidationError#<'i>> { |
| 33 | if self.is_validrust-analyzer cargo jsonschema 0.37.4 keywords/const_/impl#[ConstArrayValidator][Validate]is_valid().(instance, ctx) { |
| 34 | Okrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#Ok#(()) |
| 35 | } else { |
| 36 | Errrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#Err#(ValidationErrorrust-analyzer cargo jsonschema 0.37.4 error/ValidationError#::constant_arrayrust-analyzer cargo jsonschema 0.37.4 error/impl#[`ValidationError<'a>`]constant_array().( |
| 37 | self.locationrust-analyzer cargo jsonschema 0.37.4 keywords/const_/ConstArrayValidator#location..clonerust-analyzer cargo jsonschema 0.37.4 paths/impl#[Location][Clone]clone().(), |
| 38 | location.intorust-analyzer cargo core https://github.com/rust-lang/rust/library/core convert/impl#[T][`Into<U>`]into().(), |
| 39 | instance, |
| 40 | &self.valuerust-analyzer cargo jsonschema 0.37.4 keywords/const_/ConstArrayValidator#value., |
| 41 | )) |
| 42 | } |
| 43 | } |
| 44 | |
| 45 | #[inline] |
| 46 | fn is_validrust-analyzer cargo jsonschema 0.37.4 keywords/const_/impl#[ConstArrayValidator][Validate]is_valid().(&self, instance: &Valuerust-analyzer cargo serde_json 1.0.145 value/Value#, _ctx: &mut ValidationContextrust-analyzer cargo jsonschema 0.37.4 validator/ValidationContext#) -> bool { |
| 47 | if let Valuerust-analyzer cargo serde_json 1.0.145 value/Value#::Arrayrust-analyzer cargo serde_json 1.0.145 value/Value#Array#(instance_value) = instance { |
| 48 | cmprust-analyzer cargo jsonschema 0.37.4 ext/cmp/::equal_arraysrust-analyzer cargo jsonschema 0.37.4 ext/cmp/equal_arrays().(&self.valuerust-analyzer cargo jsonschema 0.37.4 keywords/const_/ConstArrayValidator#value., instance_value) |
| 49 | } else { |
| 50 | false |
| 51 | } |
| 52 | } |
| 53 | } |
| 54 | |
| 55 | struct ConstBooleanValidatorrust-analyzer cargo jsonschema 0.37.4 keywords/const_/ConstBooleanValidator# { |
| 56 | valuerust-analyzer cargo jsonschema 0.37.4 keywords/const_/ConstBooleanValidator#value.: bool, |
| 57 | locationrust-analyzer cargo jsonschema 0.37.4 keywords/const_/ConstBooleanValidator#location.: Locationrust-analyzer cargo jsonschema 0.37.4 paths/Location#, |
| 58 | } |
| 59 | impl ConstBooleanValidatorrust-analyzer cargo jsonschema 0.37.4 keywords/const_/ConstBooleanValidator# { |
| 60 | #[inline] |
| 61 | pub(craterust-analyzer cargo jsonschema 0.37.4 crate/) fn compilerust-analyzer cargo jsonschema 0.37.4 keywords/const_/impl#[ConstBooleanValidator]compile().<'a>(value: bool, location: Locationrust-analyzer cargo jsonschema 0.37.4 paths/Location#) -> CompilationResultrust-analyzer cargo jsonschema 0.37.4 keywords/CompilationResult#<'a> { |
| 62 | Okrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#Ok#(Boxrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc boxed/Box#::newrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc boxed/impl#[`Box<T>`]new().(ConstBooleanValidatorrust-analyzer cargo jsonschema 0.37.4 keywords/const_/ConstBooleanValidator# { valuerust-analyzer cargo jsonschema 0.37.4 keywords/const_/ConstBooleanValidator#value., locationrust-analyzer cargo jsonschema 0.37.4 keywords/const_/ConstBooleanValidator#location. })) |
| 63 | } |
| 64 | } |
| 65 | impl Validaterust-analyzer cargo jsonschema 0.37.4 validator/Validate# for ConstBooleanValidatorrust-analyzer cargo jsonschema 0.37.4 keywords/const_/ConstBooleanValidator# { |
| 66 | fn validaterust-analyzer cargo jsonschema 0.37.4 keywords/const_/impl#[ConstBooleanValidator][Validate]validate().<'i>( |
| 67 | &self, |
| 68 | instance: &'i Valuerust-analyzer cargo serde_json 1.0.145 value/Value#, |
| 69 | location: &LazyLocationrust-analyzer cargo jsonschema 0.37.4 paths/LazyLocation#, |
| 70 | ctx: &mut ValidationContextrust-analyzer cargo jsonschema 0.37.4 validator/ValidationContext#, |
| 71 | ) -> Resultrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#<(), ValidationErrorrust-analyzer cargo jsonschema 0.37.4 error/ValidationError#<'i>> { |
| 72 | if self.is_validrust-analyzer cargo jsonschema 0.37.4 keywords/const_/impl#[ConstBooleanValidator][Validate]is_valid().(instance, ctx) { |
| 73 | Okrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#Ok#(()) |
| 74 | } else { |
| 75 | Errrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#Err#(ValidationErrorrust-analyzer cargo jsonschema 0.37.4 error/ValidationError#::constant_booleanrust-analyzer cargo jsonschema 0.37.4 error/impl#[`ValidationError<'a>`]constant_boolean().( |
| 76 | self.locationrust-analyzer cargo jsonschema 0.37.4 keywords/const_/ConstBooleanValidator#location..clonerust-analyzer cargo jsonschema 0.37.4 paths/impl#[Location][Clone]clone().(), |
| 77 | location.intorust-analyzer cargo core https://github.com/rust-lang/rust/library/core convert/impl#[T][`Into<U>`]into().(), |
| 78 | instance, |
| 79 | self.valuerust-analyzer cargo jsonschema 0.37.4 keywords/const_/ConstBooleanValidator#value., |
| 80 | )) |
| 81 | } |
| 82 | } |
| 83 | |
| 84 | #[inline] |
| 85 | fn is_validrust-analyzer cargo jsonschema 0.37.4 keywords/const_/impl#[ConstBooleanValidator][Validate]is_valid().(&self, instance: &Valuerust-analyzer cargo serde_json 1.0.145 value/Value#, _ctx: &mut ValidationContextrust-analyzer cargo jsonschema 0.37.4 validator/ValidationContext#) -> bool { |
| 86 | if let Valuerust-analyzer cargo serde_json 1.0.145 value/Value#::Boolrust-analyzer cargo serde_json 1.0.145 value/Value#Bool#(instance_value) = instance { |
| 87 | &self.valuerust-analyzer cargo jsonschema 0.37.4 keywords/const_/ConstBooleanValidator#value. 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().instance_value |
| 88 | } else { |
| 89 | false |
| 90 | } |
| 91 | } |
| 92 | } |
| 93 | |
| 94 | struct ConstNullValidatorrust-analyzer cargo jsonschema 0.37.4 keywords/const_/ConstNullValidator# { |
| 95 | locationrust-analyzer cargo jsonschema 0.37.4 keywords/const_/ConstNullValidator#location.: Locationrust-analyzer cargo jsonschema 0.37.4 paths/Location#, |
| 96 | } |
| 97 | impl ConstNullValidatorrust-analyzer cargo jsonschema 0.37.4 keywords/const_/ConstNullValidator# { |
| 98 | #[inline] |
| 99 | pub(craterust-analyzer cargo jsonschema 0.37.4 crate/) fn compilerust-analyzer cargo jsonschema 0.37.4 keywords/const_/impl#[ConstNullValidator]compile().<'a>(location: Locationrust-analyzer cargo jsonschema 0.37.4 paths/Location#) -> CompilationResultrust-analyzer cargo jsonschema 0.37.4 keywords/CompilationResult#<'a> { |
| 100 | Okrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#Ok#(Boxrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc boxed/Box#::newrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc boxed/impl#[`Box<T>`]new().(ConstNullValidatorrust-analyzer cargo jsonschema 0.37.4 keywords/const_/ConstNullValidator# { locationrust-analyzer cargo jsonschema 0.37.4 keywords/const_/ConstNullValidator#location. })) |
| 101 | } |
| 102 | } |
| 103 | impl Validaterust-analyzer cargo jsonschema 0.37.4 validator/Validate# for ConstNullValidatorrust-analyzer cargo jsonschema 0.37.4 keywords/const_/ConstNullValidator# { |
| 104 | fn validaterust-analyzer cargo jsonschema 0.37.4 keywords/const_/impl#[ConstNullValidator][Validate]validate().<'i>( |
| 105 | &self, |
| 106 | instance: &'i Valuerust-analyzer cargo serde_json 1.0.145 value/Value#, |
| 107 | location: &LazyLocationrust-analyzer cargo jsonschema 0.37.4 paths/LazyLocation#, |
| 108 | ctx: &mut ValidationContextrust-analyzer cargo jsonschema 0.37.4 validator/ValidationContext#, |
| 109 | ) -> Resultrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#<(), ValidationErrorrust-analyzer cargo jsonschema 0.37.4 error/ValidationError#<'i>> { |
| 110 | if self.is_validrust-analyzer cargo jsonschema 0.37.4 keywords/const_/impl#[ConstNullValidator][Validate]is_valid().(instance, ctx) { |
| 111 | Okrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#Ok#(()) |
| 112 | } else { |
| 113 | Errrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#Err#(ValidationErrorrust-analyzer cargo jsonschema 0.37.4 error/ValidationError#::constant_nullrust-analyzer cargo jsonschema 0.37.4 error/impl#[`ValidationError<'a>`]constant_null().( |
| 114 | self.locationrust-analyzer cargo jsonschema 0.37.4 keywords/const_/ConstNullValidator#location..clonerust-analyzer cargo jsonschema 0.37.4 paths/impl#[Location][Clone]clone().(), |
| 115 | location.intorust-analyzer cargo core https://github.com/rust-lang/rust/library/core convert/impl#[T][`Into<U>`]into().(), |
| 116 | instance, |
| 117 | )) |
| 118 | } |
| 119 | } |
| 120 | #[inline] |
| 121 | fn is_validrust-analyzer cargo jsonschema 0.37.4 keywords/const_/impl#[ConstNullValidator][Validate]is_valid().(&self, instance: &Valuerust-analyzer cargo serde_json 1.0.145 value/Value#, _ctx: &mut ValidationContextrust-analyzer cargo jsonschema 0.37.4 validator/ValidationContext#) -> bool { |
| 122 | instance.is_nullrust-analyzer cargo serde_json 1.0.145 value/impl#[Value]is_null().() |
| 123 | } |
| 124 | } |
| 125 | |
| 126 | struct ConstNumberValidatorrust-analyzer cargo jsonschema 0.37.4 keywords/const_/ConstNumberValidator# { |
| 127 | // This is saved in order to ensure that the error message is not altered by precision loss |
| 128 | original_valuerust-analyzer cargo jsonschema 0.37.4 keywords/const_/ConstNumberValidator#original_value.: Numberrust-analyzer cargo serde_json 1.0.145 number/Number#, |
| 129 | locationrust-analyzer cargo jsonschema 0.37.4 keywords/const_/ConstNumberValidator#location.: Locationrust-analyzer cargo jsonschema 0.37.4 paths/Location#, |
| 130 | } |
| 131 | |
| 132 | impl ConstNumberValidatorrust-analyzer cargo jsonschema 0.37.4 keywords/const_/ConstNumberValidator# { |
| 133 | #[inline] |
| 134 | pub(craterust-analyzer cargo jsonschema 0.37.4 crate/) fn compilerust-analyzer cargo jsonschema 0.37.4 keywords/const_/impl#[ConstNumberValidator]compile().(original_value: &Numberrust-analyzer cargo serde_json 1.0.145 number/Number#, location: Locationrust-analyzer cargo jsonschema 0.37.4 paths/Location#) -> CompilationResultrust-analyzer cargo jsonschema 0.37.4 keywords/CompilationResult#<'_> { |
| 135 | Okrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#Ok#(Boxrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc boxed/Box#::newrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc boxed/impl#[`Box<T>`]new().(ConstNumberValidatorrust-analyzer cargo jsonschema 0.37.4 keywords/const_/ConstNumberValidator# { |
| 136 | original_valuerust-analyzer cargo jsonschema 0.37.4 keywords/const_/ConstNumberValidator#original_value.: original_value.clonerust-analyzer cargo serde_json 1.0.145 number/impl#[Number][Clone]clone().(), |
| 137 | locationrust-analyzer cargo jsonschema 0.37.4 keywords/const_/ConstNumberValidator#location., |
| 138 | })) |
| 139 | } |
| 140 | } |
| 141 | |
| 142 | impl Validaterust-analyzer cargo jsonschema 0.37.4 validator/Validate# for ConstNumberValidatorrust-analyzer cargo jsonschema 0.37.4 keywords/const_/ConstNumberValidator# { |
| 143 | fn validaterust-analyzer cargo jsonschema 0.37.4 keywords/const_/impl#[ConstNumberValidator][Validate]validate().<'i>( |
| 144 | &self, |
| 145 | instance: &'i Valuerust-analyzer cargo serde_json 1.0.145 value/Value#, |
| 146 | location: &LazyLocationrust-analyzer cargo jsonschema 0.37.4 paths/LazyLocation#, |
| 147 | ctx: &mut ValidationContextrust-analyzer cargo jsonschema 0.37.4 validator/ValidationContext#, |
| 148 | ) -> Resultrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#<(), ValidationErrorrust-analyzer cargo jsonschema 0.37.4 error/ValidationError#<'i>> { |
| 149 | if self.is_validrust-analyzer cargo jsonschema 0.37.4 keywords/const_/impl#[ConstNumberValidator][Validate]is_valid().(instance, ctx) { |
| 150 | Okrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#Ok#(()) |
| 151 | } else { |
| 152 | Errrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#Err#(ValidationErrorrust-analyzer cargo jsonschema 0.37.4 error/ValidationError#::constant_numberrust-analyzer cargo jsonschema 0.37.4 error/impl#[`ValidationError<'a>`]constant_number().( |
| 153 | self.locationrust-analyzer cargo jsonschema 0.37.4 keywords/const_/ConstNumberValidator#location..clonerust-analyzer cargo jsonschema 0.37.4 paths/impl#[Location][Clone]clone().(), |
| 154 | location.intorust-analyzer cargo core https://github.com/rust-lang/rust/library/core convert/impl#[T][`Into<U>`]into().(), |
| 155 | instance, |
| 156 | &self.original_valuerust-analyzer cargo jsonschema 0.37.4 keywords/const_/ConstNumberValidator#original_value., |
| 157 | )) |
| 158 | } |
| 159 | } |
| 160 | |
| 161 | #[inline] |
| 162 | fn is_validrust-analyzer cargo jsonschema 0.37.4 keywords/const_/impl#[ConstNumberValidator][Validate]is_valid().(&self, instance: &Valuerust-analyzer cargo serde_json 1.0.145 value/Value#, _ctx: &mut ValidationContextrust-analyzer cargo jsonschema 0.37.4 validator/ValidationContext#) -> bool { |
| 163 | if let Valuerust-analyzer cargo serde_json 1.0.145 value/Value#::Numberrust-analyzer cargo serde_json 1.0.145 value/Value#Number#(item) = instance { |
| 164 | craterust-analyzer cargo jsonschema 0.37.4 crate/::extrust-analyzer cargo jsonschema 0.37.4 ext/::cmprust-analyzer cargo jsonschema 0.37.4 ext/cmp/::equal_numbersrust-analyzer cargo jsonschema 0.37.4 ext/cmp/equal_numbers().(item, &self.original_valuerust-analyzer cargo jsonschema 0.37.4 keywords/const_/ConstNumberValidator#original_value.) |
| 165 | } else { |
| 166 | false |
| 167 | } |
| 168 | } |
| 169 | } |
| 170 | |
| 171 | pub(craterust-analyzer cargo jsonschema 0.37.4 crate/) struct ConstObjectValidatorrust-analyzer cargo jsonschema 0.37.4 keywords/const_/ConstObjectValidator# { |
| 172 | valuerust-analyzer cargo jsonschema 0.37.4 keywords/const_/ConstObjectValidator#value.: Maprust-analyzer cargo serde_json 1.0.145 map/Map#<Stringrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/String#, Valuerust-analyzer cargo serde_json 1.0.145 value/Value#>, |
| 173 | locationrust-analyzer cargo jsonschema 0.37.4 keywords/const_/ConstObjectValidator#location.: Locationrust-analyzer cargo jsonschema 0.37.4 paths/Location#, |
| 174 | } |
| 175 | |
| 176 | impl ConstObjectValidatorrust-analyzer cargo jsonschema 0.37.4 keywords/const_/ConstObjectValidator# { |
| 177 | #[inline] |
| 178 | pub(craterust-analyzer cargo jsonschema 0.37.4 crate/) fn compilerust-analyzer cargo jsonschema 0.37.4 keywords/const_/impl#[ConstObjectValidator]compile().(value: &Maprust-analyzer cargo serde_json 1.0.145 map/Map#<Stringrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/String#, Valuerust-analyzer cargo serde_json 1.0.145 value/Value#>, location: Locationrust-analyzer cargo jsonschema 0.37.4 paths/Location#) -> CompilationResultrust-analyzer cargo jsonschema 0.37.4 keywords/CompilationResult#<'_> { |
| 179 | Okrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#Ok#(Boxrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc boxed/Box#::newrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc boxed/impl#[`Box<T>`]new().(ConstObjectValidatorrust-analyzer cargo jsonschema 0.37.4 keywords/const_/ConstObjectValidator# { |
| 180 | valuerust-analyzer cargo jsonschema 0.37.4 keywords/const_/ConstObjectValidator#value.: value.clonerust-analyzer cargo serde_json 1.0.145 map/impl#[`Map<String, Value>`][Clone]clone().(), |
| 181 | locationrust-analyzer cargo jsonschema 0.37.4 keywords/const_/ConstObjectValidator#location., |
| 182 | })) |
| 183 | } |
| 184 | } |
| 185 | |
| 186 | impl Validaterust-analyzer cargo jsonschema 0.37.4 validator/Validate# for ConstObjectValidatorrust-analyzer cargo jsonschema 0.37.4 keywords/const_/ConstObjectValidator# { |
| 187 | fn validaterust-analyzer cargo jsonschema 0.37.4 keywords/const_/impl#[ConstObjectValidator][Validate]validate().<'i>( |
| 188 | &self, |
| 189 | instance: &'i Valuerust-analyzer cargo serde_json 1.0.145 value/Value#, |
| 190 | location: &LazyLocationrust-analyzer cargo jsonschema 0.37.4 paths/LazyLocation#, |
| 191 | ctx: &mut ValidationContextrust-analyzer cargo jsonschema 0.37.4 validator/ValidationContext#, |
| 192 | ) -> Resultrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#<(), ValidationErrorrust-analyzer cargo jsonschema 0.37.4 error/ValidationError#<'i>> { |
| 193 | if self.is_validrust-analyzer cargo jsonschema 0.37.4 keywords/const_/impl#[ConstObjectValidator][Validate]is_valid().(instance, ctx) { |
| 194 | Okrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#Ok#(()) |
| 195 | } else { |
| 196 | Errrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#Err#(ValidationErrorrust-analyzer cargo jsonschema 0.37.4 error/ValidationError#::constant_objectrust-analyzer cargo jsonschema 0.37.4 error/impl#[`ValidationError<'a>`]constant_object().( |
| 197 | self.locationrust-analyzer cargo jsonschema 0.37.4 keywords/const_/ConstObjectValidator#location..clonerust-analyzer cargo jsonschema 0.37.4 paths/impl#[Location][Clone]clone().(), |
| 198 | location.intorust-analyzer cargo core https://github.com/rust-lang/rust/library/core convert/impl#[T][`Into<U>`]into().(), |
| 199 | instance, |
| 200 | &self.valuerust-analyzer cargo jsonschema 0.37.4 keywords/const_/ConstObjectValidator#value., |
| 201 | )) |
| 202 | } |
| 203 | } |
| 204 | |
| 205 | #[inline] |
| 206 | fn is_validrust-analyzer cargo jsonschema 0.37.4 keywords/const_/impl#[ConstObjectValidator][Validate]is_valid().(&self, instance: &Valuerust-analyzer cargo serde_json 1.0.145 value/Value#, _ctx: &mut ValidationContextrust-analyzer cargo jsonschema 0.37.4 validator/ValidationContext#) -> bool { |
| 207 | if let Valuerust-analyzer cargo serde_json 1.0.145 value/Value#::Objectrust-analyzer cargo serde_json 1.0.145 value/Value#Object#(item) = instance { |
| 208 | cmprust-analyzer cargo jsonschema 0.37.4 ext/cmp/::equal_objectsrust-analyzer cargo jsonschema 0.37.4 ext/cmp/equal_objects().(&self.valuerust-analyzer cargo jsonschema 0.37.4 keywords/const_/ConstObjectValidator#value., item) |
| 209 | } else { |
| 210 | false |
| 211 | } |
| 212 | } |
| 213 | } |
| 214 | |
| 215 | pub(craterust-analyzer cargo jsonschema 0.37.4 crate/) struct ConstStringValidatorrust-analyzer cargo jsonschema 0.37.4 keywords/const_/ConstStringValidator# { |
| 216 | valuerust-analyzer cargo jsonschema 0.37.4 keywords/const_/ConstStringValidator#value.: Stringrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/String#, |
| 217 | locationrust-analyzer cargo jsonschema 0.37.4 keywords/const_/ConstStringValidator#location.: Locationrust-analyzer cargo jsonschema 0.37.4 paths/Location#, |
| 218 | } |
| 219 | |
| 220 | impl ConstStringValidatorrust-analyzer cargo jsonschema 0.37.4 keywords/const_/ConstStringValidator# { |
| 221 | #[inline] |
| 222 | pub(craterust-analyzer cargo jsonschema 0.37.4 crate/) fn compilerust-analyzer cargo jsonschema 0.37.4 keywords/const_/impl#[ConstStringValidator]compile().(value: &str, location: Locationrust-analyzer cargo jsonschema 0.37.4 paths/Location#) -> CompilationResultrust-analyzer cargo jsonschema 0.37.4 keywords/CompilationResult#<'_> { |
| 223 | Okrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#Ok#(Boxrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc boxed/Box#::newrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc boxed/impl#[`Box<T>`]new().(ConstStringValidatorrust-analyzer cargo jsonschema 0.37.4 keywords/const_/ConstStringValidator# { |
| 224 | valuerust-analyzer cargo jsonschema 0.37.4 keywords/const_/ConstStringValidator#value.: value.to_stringrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/impl#[T][ToString]to_string().(), |
| 225 | locationrust-analyzer cargo jsonschema 0.37.4 keywords/const_/ConstStringValidator#location., |
| 226 | })) |
| 227 | } |
| 228 | } |
| 229 | |
| 230 | impl Validaterust-analyzer cargo jsonschema 0.37.4 validator/Validate# for ConstStringValidatorrust-analyzer cargo jsonschema 0.37.4 keywords/const_/ConstStringValidator# { |
| 231 | fn validaterust-analyzer cargo jsonschema 0.37.4 keywords/const_/impl#[ConstStringValidator][Validate]validate().<'i>( |
| 232 | &self, |
| 233 | instance: &'i Valuerust-analyzer cargo serde_json 1.0.145 value/Value#, |
| 234 | location: &LazyLocationrust-analyzer cargo jsonschema 0.37.4 paths/LazyLocation#, |
| 235 | ctx: &mut ValidationContextrust-analyzer cargo jsonschema 0.37.4 validator/ValidationContext#, |
| 236 | ) -> Resultrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#<(), ValidationErrorrust-analyzer cargo jsonschema 0.37.4 error/ValidationError#<'i>> { |
| 237 | if self.is_validrust-analyzer cargo jsonschema 0.37.4 keywords/const_/impl#[ConstStringValidator][Validate]is_valid().(instance, ctx) { |
| 238 | Okrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#Ok#(()) |
| 239 | } else { |
| 240 | Errrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#Err#(ValidationErrorrust-analyzer cargo jsonschema 0.37.4 error/ValidationError#::constant_stringrust-analyzer cargo jsonschema 0.37.4 error/impl#[`ValidationError<'a>`]constant_string().( |
| 241 | self.locationrust-analyzer cargo jsonschema 0.37.4 keywords/const_/ConstStringValidator#location..clonerust-analyzer cargo jsonschema 0.37.4 paths/impl#[Location][Clone]clone().(), |
| 242 | location.intorust-analyzer cargo core https://github.com/rust-lang/rust/library/core convert/impl#[T][`Into<U>`]into().(), |
| 243 | instance, |
| 244 | &self.valuerust-analyzer cargo jsonschema 0.37.4 keywords/const_/ConstStringValidator#value., |
| 245 | )) |
| 246 | } |
| 247 | } |
| 248 | |
| 249 | #[inline] |
| 250 | fn is_validrust-analyzer cargo jsonschema 0.37.4 keywords/const_/impl#[ConstStringValidator][Validate]is_valid().(&self, instance: &Valuerust-analyzer cargo serde_json 1.0.145 value/Value#, _ctx: &mut ValidationContextrust-analyzer cargo jsonschema 0.37.4 validator/ValidationContext#) -> bool { |
| 251 | if let Valuerust-analyzer cargo serde_json 1.0.145 value/Value#::Stringrust-analyzer cargo serde_json 1.0.145 value/Value#String#(item) = instance { |
| 252 | &self.valuerust-analyzer cargo jsonschema 0.37.4 keywords/const_/ConstStringValidator#value. 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().item |
| 253 | } else { |
| 254 | false |
| 255 | } |
| 256 | } |
| 257 | } |
| 258 | |
| 259 | #[inline] |
| 260 | pub(craterust-analyzer cargo jsonschema 0.37.4 crate/) fn compilerust-analyzer cargo jsonschema 0.37.4 keywords/const_/compile().<'a>( |
| 261 | ctx: &compilerrust-analyzer cargo jsonschema 0.37.4 compiler/::Contextrust-analyzer cargo jsonschema 0.37.4 compiler/Context#, |
| 262 | _: &'a Maprust-analyzer cargo serde_json 1.0.145 map/Map#<Stringrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/String#, Valuerust-analyzer cargo serde_json 1.0.145 value/Value#>, |
| 263 | schema: &'a Valuerust-analyzer cargo serde_json 1.0.145 value/Value#, |
| 264 | ) -> Optionrust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#<CompilationResultrust-analyzer cargo jsonschema 0.37.4 keywords/CompilationResult#<'a>> { |
| 265 | let location = ctx.locationrust-analyzer cargo jsonschema 0.37.4 compiler/impl#[`Context<'a>`]location().().joinrust-analyzer cargo jsonschema 0.37.4 paths/impl#[Location]join().("const"); |
| 266 | match schema { |
| 267 | Valuerust-analyzer cargo serde_json 1.0.145 value/Value#::Arrayrust-analyzer cargo serde_json 1.0.145 value/Value#Array#(items) => Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#(ConstArrayValidatorrust-analyzer cargo jsonschema 0.37.4 keywords/const_/ConstArrayValidator#::compilerust-analyzer cargo jsonschema 0.37.4 keywords/const_/impl#[ConstArrayValidator]compile().(items, location)), |
| 268 | Valuerust-analyzer cargo serde_json 1.0.145 value/Value#::Boolrust-analyzer cargo serde_json 1.0.145 value/Value#Bool#(item) => Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#(ConstBooleanValidatorrust-analyzer cargo jsonschema 0.37.4 keywords/const_/ConstBooleanValidator#::compilerust-analyzer cargo jsonschema 0.37.4 keywords/const_/impl#[ConstBooleanValidator]compile().(*rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/deref/impl#[`&T`][Deref]deref().item, location)), |
| 269 | Valuerust-analyzer cargo serde_json 1.0.145 value/Value#::Nullrust-analyzer cargo serde_json 1.0.145 value/Value#Null# => Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#(ConstNullValidatorrust-analyzer cargo jsonschema 0.37.4 keywords/const_/ConstNullValidator#::compilerust-analyzer cargo jsonschema 0.37.4 keywords/const_/impl#[ConstNullValidator]compile().(location)), |
| 270 | Valuerust-analyzer cargo serde_json 1.0.145 value/Value#::Numberrust-analyzer cargo serde_json 1.0.145 value/Value#Number#(item) => Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#(ConstNumberValidatorrust-analyzer cargo jsonschema 0.37.4 keywords/const_/ConstNumberValidator#::compilerust-analyzer cargo jsonschema 0.37.4 keywords/const_/impl#[ConstNumberValidator]compile().(item, location)), |
| 271 | Valuerust-analyzer cargo serde_json 1.0.145 value/Value#::Objectrust-analyzer cargo serde_json 1.0.145 value/Value#Object#(map) => Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#(ConstObjectValidatorrust-analyzer cargo jsonschema 0.37.4 keywords/const_/ConstObjectValidator#::compilerust-analyzer cargo jsonschema 0.37.4 keywords/const_/impl#[ConstObjectValidator]compile().(map, location)), |
| 272 | Valuerust-analyzer cargo serde_json 1.0.145 value/Value#::Stringrust-analyzer cargo serde_json 1.0.145 value/Value#String#(string) => Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#(ConstStringValidatorrust-analyzer cargo jsonschema 0.37.4 keywords/const_/ConstStringValidator#::compilerust-analyzer cargo jsonschema 0.37.4 keywords/const_/impl#[ConstStringValidator]compile().(string, location)), |
| 273 | } |
| 274 | } |
| 275 | |
| 276 | #[cfg(test)] |
| 277 | mod testsrust-analyzer cargo jsonschema 0.37.4 keywords/const_/tests/ { |
| 278 | use craterust-analyzer cargo jsonschema 0.37.4 crate/::tests_utilrust-analyzer cargo jsonschema 0.37.4 tests_util/; |
| 279 | use serde_jsonrust-analyzer cargo serde_json 1.0.145 crate/::{jsonrust-analyzer cargo serde_json 1.0.145 macros/json!, Valuerust-analyzer cargo serde_json 1.0.145 value/Value#}; |
| 280 | use test_caserust-analyzer cargo test-case 3.3.1 crate/::test_caserust-analyzer cargo test-case-macros 3.3.1 test_case:; |
| 281 | |
| 282 | #[test_caserust-analyzer cargo test-case-macros 3.3.1 test_case:(&jsonrust-analyzer cargo serde_json 1.0.145 macros/json!!({"const": 1}), &jsonrust-analyzer cargo serde_json 1.0.145 macros/json!!(2), "/const")] |
| 283 | #[test_caserust-analyzer cargo test-case-macros 3.3.1 test_case:(&jsonrust-analyzer cargo serde_json 1.0.145 macros/json!!({"const": null}), &jsonrust-analyzer cargo serde_json 1.0.145 macros/json!!(3), "/const")] |
| 284 | #[test_caserust-analyzer cargo test-case-macros 3.3.1 test_case:(&jsonrust-analyzer cargo serde_json 1.0.145 macros/json!!({"const": false}), &jsonrust-analyzer cargo serde_json 1.0.145 macros/json!!(4), "/const")] |
| 285 | #[test_caserust-analyzer cargo test-case-macros 3.3.1 test_case:(&jsonrust-analyzer cargo serde_json 1.0.145 macros/json!!({"const": []}), &jsonrust-analyzer cargo serde_json 1.0.145 macros/json!!(5), "/const")] |
| 286 | #[test_caserust-analyzer cargo test-case-macros 3.3.1 test_case:(&jsonrust-analyzer cargo serde_json 1.0.145 macros/json!!({"const": {}}), &jsonrust-analyzer cargo serde_json 1.0.145 macros/json!!(6), "/const")] |
| 287 | #[test_caserust-analyzer cargo test-case-macros 3.3.1 test_case:(&jsonrust-analyzer cargo serde_json 1.0.145 macros/json!!({"const": ""}), &jsonrust-analyzer cargo serde_json 1.0.145 macros/json!!(7), "/const")] |
| 288 | fn locationrust-analyzer cargo jsonschema 0.37.4 keywords/const_/tests/location().(schema: &Valuerust-analyzer cargo serde_json 1.0.145 value/Value#, instance: &Valuerust-analyzer cargo serde_json 1.0.145 value/Value#, expected: &str) { |
| 289 | tests_utilrust-analyzer cargo jsonschema 0.37.4 tests_util/::assert_schema_locationrust-analyzer cargo jsonschema 0.37.4 tests_util/assert_schema_location().(schema, instance, expected); |
| 290 | } |
| 291 | |
| 292 | // Tests for arbitrary-precision const validation |
| 293 | #[cfg(feature = "arbitrary-precision")] |
| 294 | mod arbitrary_precisionrust-analyzer cargo jsonschema 0.37.4 keywords/const_/tests/arbitrary_precision/ { |
| 295 | use craterust-analyzer cargo jsonschema 0.37.4 crate/::tests_utilrust-analyzer cargo jsonschema 0.37.4 tests_util/; |
| 296 | use serde_jsonrust-analyzer cargo serde_json 1.0.145 crate/::Valuerust-analyzer cargo serde_json 1.0.145 value/Value#; |
| 297 | use test_caserust-analyzer cargo test-case 3.3.1 crate/::test_caserust-analyzer cargo test-case-macros 3.3.1 test_case:; |
| 298 | |
| 299 | fn parse_jsonrust-analyzer cargo jsonschema 0.37.4 keywords/const_/tests/arbitrary_precision/parse_json().(json: &str) -> Valuerust-analyzer cargo serde_json 1.0.145 value/Value# { |
| 300 | serde_jsonrust-analyzer cargo serde_json 1.0.145 crate/::from_strrust-analyzer cargo serde_json 1.0.145 de/from_str().(json).unwraprust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]unwrap().() |
| 301 | } |
| 302 | |
| 303 | #[test_caserust-analyzer cargo test-case-macros 3.3.1 test_case:(r#"{"const": 18446744073709551617}"#, "18446744073709551617", true; "large int exact match")] |
| 304 | #[test_caserust-analyzer cargo test-case-macros 3.3.1 test_case:(r#"{"const": 18446744073709551617}"#, "18446744073709551616", false; "large int different by one")] |
| 305 | #[test_caserust-analyzer cargo test-case-macros 3.3.1 test_case:(r#"{"const": 18446744073709551617}"#, "18446744073709551618", false; "large int different by one above")] |
| 306 | #[test_caserust-analyzer cargo test-case-macros 3.3.1 test_case:(r#"{"const": -9223372036854775809}"#, "-9223372036854775809", true; "large negative int match")] |
| 307 | #[test_caserust-analyzer cargo test-case-macros 3.3.1 test_case:(r#"{"const": -9223372036854775809}"#, "-9223372036854775808", false; "large negative int different")] |
| 308 | #[test_caserust-analyzer cargo test-case-macros 3.3.1 test_case:(r#"{"const": 0.1}"#, "0.1", true; "decimal exact match")] |
| 309 | #[test_caserust-analyzer cargo test-case-macros 3.3.1 test_case:(r#"{"const": 0.1}"#, "0.10000000000000001", false; "decimal precision difference")] |
| 310 | fn const_arbitrary_precisionrust-analyzer cargo jsonschema 0.37.4 keywords/const_/tests/arbitrary_precision/const_arbitrary_precision().(schema_json: &str, instance_json: &str, expected_valid: bool) { |
| 311 | let schema = parse_jsonrust-analyzer cargo jsonschema 0.37.4 keywords/const_/tests/arbitrary_precision/parse_json().(schema_json); |
| 312 | let instance = parse_jsonrust-analyzer cargo jsonschema 0.37.4 keywords/const_/tests/arbitrary_precision/parse_json().(instance_json); |
| 313 | if expected_valid { |
| 314 | tests_utilrust-analyzer cargo jsonschema 0.37.4 tests_util/::is_validrust-analyzer cargo jsonschema 0.37.4 tests_util/is_valid().(&schema, &instance); |
| 315 | } else { |
| 316 | tests_utilrust-analyzer cargo jsonschema 0.37.4 tests_util/::is_not_validrust-analyzer cargo jsonschema 0.37.4 tests_util/is_not_valid().(&schema, &instance); |
| 317 | } |
| 318 | } |
| 319 | } |
| 320 | } |