Debian Codegraph @

src/keywords/not.rs

raw symbols SCIP
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 keywordsrust-analyzer cargo jsonschema 0.37.4 keywords/::CompilationResultrust-analyzer cargo jsonschema 0.37.4 keywords/CompilationResult#,
5 noderust-analyzer cargo jsonschema 0.37.4 node/::SchemaNoderust-analyzer cargo jsonschema 0.37.4 node/SchemaNode#,
6 pathsrust-analyzer cargo jsonschema 0.37.4 paths/::LazyLocationrust-analyzer cargo jsonschema 0.37.4 paths/LazyLocation#,
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#, Valuerust-analyzer cargo serde_json 1.0.145 value/Value#};
10
11 pub(craterust-analyzer cargo jsonschema 0.37.4 crate/) struct NotValidatorrust-analyzer cargo jsonschema 0.37.4 keywords/not/NotValidator# {
12 // needed only for error representation
13 originalrust-analyzer cargo jsonschema 0.37.4 keywords/not/NotValidator#original.: Valuerust-analyzer cargo serde_json 1.0.145 value/Value#,
14 noderust-analyzer cargo jsonschema 0.37.4 keywords/not/NotValidator#node.: SchemaNoderust-analyzer cargo jsonschema 0.37.4 node/SchemaNode#,
15 }
16
17 impl NotValidatorrust-analyzer cargo jsonschema 0.37.4 keywords/not/NotValidator# {
18 #[inline]
19 pub(craterust-analyzer cargo jsonschema 0.37.4 crate/) fn compilerust-analyzer cargo jsonschema 0.37.4 keywords/not/impl#[NotValidator]compile().<'a>(ctx: &compilerrust-analyzer cargo jsonschema 0.37.4 compiler/::Contextrust-analyzer cargo jsonschema 0.37.4 compiler/Context#, schema: &'a Valuerust-analyzer cargo serde_json 1.0.145 value/Value#) -> CompilationResultrust-analyzer cargo jsonschema 0.37.4 keywords/CompilationResult#<'a> {
20 let ctx = ctx.new_at_locationrust-analyzer cargo jsonschema 0.37.4 compiler/impl#[`Context<'a>`]new_at_location().("not");
21 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().(NotValidatorrust-analyzer cargo jsonschema 0.37.4 keywords/not/NotValidator# {
22 originalrust-analyzer cargo jsonschema 0.37.4 keywords/not/NotValidator#original.: schema.clonerust-analyzer cargo serde_json 1.0.145 value/impl#[Value][Clone]clone().(),
23 noderust-analyzer cargo jsonschema 0.37.4 keywords/not/NotValidator#node.: compilerrust-analyzer cargo jsonschema 0.37.4 compiler/::compilerust-analyzer cargo jsonschema 0.37.4 compiler/compile().(&ctx, ctx.as_resource_refrust-analyzer cargo jsonschema 0.37.4 compiler/impl#[`Context<'a>`]as_resource_ref().(schema))?rust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`][Try]branch().,
24 }))
25 }
26 }
27
28 impl Validaterust-analyzer cargo jsonschema 0.37.4 validator/Validate# for NotValidatorrust-analyzer cargo jsonschema 0.37.4 keywords/not/NotValidator# {
29 fn is_validrust-analyzer cargo jsonschema 0.37.4 keywords/not/impl#[NotValidator][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 {
30 !rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/bit/impl#[bool][Not]not().self.noderust-analyzer cargo jsonschema 0.37.4 keywords/not/NotValidator#node..is_validrust-analyzer cargo jsonschema 0.37.4 node/impl#[SchemaNode][Validate]is_valid().(instance, ctx)
31 }
32
33 fn validaterust-analyzer cargo jsonschema 0.37.4 keywords/not/impl#[NotValidator][Validate]validate().<'i>(
34 &self,
35 instance: &'i Valuerust-analyzer cargo serde_json 1.0.145 value/Value#,
36 location: &LazyLocationrust-analyzer cargo jsonschema 0.37.4 paths/LazyLocation#,
37 ctx: &mut ValidationContextrust-analyzer cargo jsonschema 0.37.4 validator/ValidationContext#,
38 ) -> Resultrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#<(), ValidationErrorrust-analyzer cargo jsonschema 0.37.4 error/ValidationError#<'i>> {
39 if self.is_validrust-analyzer cargo jsonschema 0.37.4 keywords/not/impl#[NotValidator][Validate]is_valid().(instance, ctx) {
40 Okrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#Ok#(())
41 } else {
42 Errrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#Err#(ValidationErrorrust-analyzer cargo jsonschema 0.37.4 error/ValidationError#::notrust-analyzer cargo jsonschema 0.37.4 error/impl#[`ValidationError<'a>`]not().(
43 self.noderust-analyzer cargo jsonschema 0.37.4 keywords/not/NotValidator#node..locationrust-analyzer cargo jsonschema 0.37.4 node/impl#[SchemaNode]location().().clonerust-analyzer cargo jsonschema 0.37.4 paths/impl#[Location][Clone]clone().(),
44 location.intorust-analyzer cargo core https://github.com/rust-lang/rust/library/core convert/impl#[T][`Into<U>`]into().(),
45 instance,
46 self.originalrust-analyzer cargo jsonschema 0.37.4 keywords/not/NotValidator#original..clonerust-analyzer cargo serde_json 1.0.145 value/impl#[Value][Clone]clone().(),
47 ))
48 }
49 }
50 }
51
52 #[inline]
53 pub(craterust-analyzer cargo jsonschema 0.37.4 crate/) fn compilerust-analyzer cargo jsonschema 0.37.4 keywords/not/compile().<'a>(
54 ctx: &compilerrust-analyzer cargo jsonschema 0.37.4 compiler/::Contextrust-analyzer cargo jsonschema 0.37.4 compiler/Context#,
55 _: &'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#>,
56 schema: &'a Valuerust-analyzer cargo serde_json 1.0.145 value/Value#,
57 ) -> Optionrust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#<CompilationResultrust-analyzer cargo jsonschema 0.37.4 keywords/CompilationResult#<'a>> {
58 Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#(NotValidatorrust-analyzer cargo jsonschema 0.37.4 keywords/not/NotValidator#::compilerust-analyzer cargo jsonschema 0.37.4 keywords/not/impl#[NotValidator]compile().(ctx, schema))
59 }
60
61 #[cfg(test)]
62 mod testsrust-analyzer cargo jsonschema 0.37.4 keywords/not/tests/ {
63 use craterust-analyzer cargo jsonschema 0.37.4 crate/::tests_utilrust-analyzer cargo jsonschema 0.37.4 tests_util/;
64 use serde_jsonrust-analyzer cargo serde_json 1.0.145 crate/::jsonrust-analyzer cargo serde_json 1.0.145 macros/json!;
65
66 #[testrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/test:]
67 fn locationrust-analyzer cargo jsonschema 0.37.4 keywords/not/tests/location().() {
68 tests_utilrust-analyzer cargo jsonschema 0.37.4 tests_util/::assert_schema_locationrust-analyzer cargo jsonschema 0.37.4 tests_util/assert_schema_location().(
69 &jsonrust-analyzer cargo serde_json 1.0.145 macros/json!!({"not": {"type": "string"}}),
70 &jsonrust-analyzer cargo serde_json 1.0.145 macros/json!!("foo"),
71 "/not",
72 );
73 }
74 }