diff --git a/crates/samples/components/json_validator/Cargo.toml b/crates/samples/components/json_validator/Cargo.toml index d7e58b6abe..abd76eb628 100644 --- a/crates/samples/components/json_validator/Cargo.toml +++ b/crates/samples/components/json_validator/Cargo.toml @@ -8,7 +8,7 @@ publish = false crate-type = ["cdylib"] [dependencies] -jsonschema = { version = "0.19", default-features = false } +jsonschema = { version = "0.20", default-features = false } serde_json = {version = "1.0", default-features = false } [dependencies.windows] diff --git a/crates/samples/components/json_validator/src/lib.rs b/crates/samples/components/json_validator/src/lib.rs index f62f43a3bf..a679531ce9 100644 --- a/crates/samples/components/json_validator/src/lib.rs +++ b/crates/samples/components/json_validator/src/lib.rs @@ -1,4 +1,4 @@ -use jsonschema::JSONSchema; +use jsonschema::Validator; use windows::{core::*, Win32::Foundation::*, Win32::System::Com::*}; // Creates a JSON validator object with the given schema. The returned handle must be freed @@ -35,7 +35,7 @@ unsafe extern "system" fn ValidateJson( #[no_mangle] unsafe extern "system" fn CloseJsonValidator(handle: usize) { if handle != 0 { - _ = Box::from_raw(handle as *mut JSONSchema); + _ = Box::from_raw(handle as *mut Validator); } } @@ -43,8 +43,8 @@ unsafe extern "system" fn CloseJsonValidator(handle: usize) { unsafe fn create_validator(schema: *const u8, schema_len: usize, handle: *mut usize) -> Result<()> { let schema = json_from_raw_parts(schema, schema_len)?; - let compiled = JSONSchema::compile(&schema) - .map_err(|error| Error::new(E_INVALIDARG, error.to_string()))?; + let compiled = + Validator::new(&schema).map_err(|error| Error::new(E_INVALIDARG, error.to_string()))?; if handle.is_null() { return Err(E_POINTER.into()); @@ -70,9 +70,9 @@ unsafe fn validate( let value = json_from_raw_parts(value, value_len)?; - // This looks a bit tricky but we're just turning the opaque handle into `JSONSchema` pointer + // This looks a bit tricky but we're just turning the opaque handle into `Validator` pointer // and then returning a reference to avoid taking ownership of it. - let schema = &*(handle as *const JSONSchema); + let schema = &*(handle as *const Validator); if schema.is_valid(&value) { if !sanitized_value.is_null() && !sanitized_value_len.is_null() { diff --git a/crates/samples/components/json_validator_winrt/Cargo.toml b/crates/samples/components/json_validator_winrt/Cargo.toml index 534a077a56..52719dd88e 100644 --- a/crates/samples/components/json_validator_winrt/Cargo.toml +++ b/crates/samples/components/json_validator_winrt/Cargo.toml @@ -9,7 +9,7 @@ name = "sample" crate-type = ["cdylib"] [dependencies] -jsonschema = { version = "0.19", default-features = false } +jsonschema = { version = "0.20", default-features = false } serde_json = {version = "1.0", default-features = false } [dependencies.windows] diff --git a/crates/samples/components/json_validator_winrt/src/lib.rs b/crates/samples/components/json_validator_winrt/src/lib.rs index b3a9fafa36..df9c500f92 100644 --- a/crates/samples/components/json_validator_winrt/src/lib.rs +++ b/crates/samples/components/json_validator_winrt/src/lib.rs @@ -1,12 +1,12 @@ mod bindings; -use jsonschema::JSONSchema; +use jsonschema::Validator; use windows::{core::*, Win32::Foundation::*, Win32::System::WinRT::*}; // The `JsonValidator` struct represents the implementation of the `JsonValidator` class. // The `implement` attribute provides the boilerplate COM and WinRT implementation support. #[implement(bindings::JsonValidator)] struct JsonValidator { - schema: JSONSchema, + schema: Validator, } // Implement the `IJsonValidator` interface. @@ -49,8 +49,8 @@ impl bindings::IJsonValidatorFactory_Impl for JsonValidatorFactory_Impl { fn CreateInstance(&self, schema: &HSTRING) -> Result { let schema = json_from_hstring(schema)?; - let schema = JSONSchema::compile(&schema) - .map_err(|error| Error::new(E_INVALIDARG, error.to_string()))?; + let schema = + Validator::new(&schema).map_err(|error| Error::new(E_INVALIDARG, error.to_string()))?; Ok(JsonValidator { schema }.into()) }