Skip to content

Commit 9442d37

Browse files
committed
chore: Update API for new jsonschema exports
1 parent 947d32b commit 9442d37

File tree

2 files changed

+9
-9
lines changed

2 files changed

+9
-9
lines changed

buttplug/src/core/message/serializer/json_serializer.rs

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ use crate::core::{
2929
ButtplugServerMessageVariant,
3030
},
3131
};
32-
use jsonschema::JSONSchema;
32+
use jsonschema::Validator;
3333
use once_cell::sync::OnceCell;
3434
use serde::{Deserialize, Serialize};
3535
use serde_json::{Deserializer, Value};
@@ -39,14 +39,14 @@ static MESSAGE_JSON_SCHEMA: &str =
3939
include_str!("../../../../buttplug-schema/schema/buttplug-schema.json");
4040

4141
/// Creates a [jsonschema::JSONSchema] validator using the built in buttplug message schema.
42-
pub fn create_message_validator() -> JSONSchema {
42+
pub fn create_message_validator() -> Validator {
4343
let schema: serde_json::Value =
4444
serde_json::from_str(MESSAGE_JSON_SCHEMA).expect("Built in schema better be valid");
45-
JSONSchema::compile(&schema).expect("Built in schema better be valid")
45+
Validator::new(&schema).expect("Built in schema better be valid")
4646
}
4747
pub struct ButtplugServerJSONSerializer {
4848
pub(super) message_version: OnceCell<message::ButtplugMessageSpecVersion>,
49-
validator: JSONSchema,
49+
validator: Validator,
5050
}
5151

5252
impl Default for ButtplugServerJSONSerializer {
@@ -83,7 +83,7 @@ where
8383
}
8484

8585
pub fn deserialize_to_message<T>(
86-
validator: &JSONSchema,
86+
validator: &Validator,
8787
msg_str: &str,
8888
) -> Result<Vec<T>, ButtplugSerializerError>
8989
where
@@ -319,7 +319,7 @@ impl ButtplugMessageSerializer for ButtplugServerJSONSerializer {
319319
}
320320

321321
pub struct ButtplugClientJSONSerializerImpl {
322-
validator: JSONSchema,
322+
validator: Validator,
323323
}
324324

325325
impl Default for ButtplugClientJSONSerializerImpl {

buttplug/src/util/json.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -11,10 +11,10 @@
1111
//! jsonschema library.
1212
1313
use crate::core::message::serializer::ButtplugSerializerError;
14-
use jsonschema::JSONSchema;
14+
use jsonschema::Validator;
1515

1616
pub struct JSONValidator {
17-
schema: JSONSchema,
17+
schema: Validator,
1818
}
1919

2020
impl JSONValidator {
@@ -26,7 +26,7 @@ impl JSONValidator {
2626
pub fn new(schema: &str) -> Self {
2727
let schema_json: serde_json::Value =
2828
serde_json::from_str(schema).expect("Built in schema better be valid");
29-
let schema = JSONSchema::compile(&schema_json).expect("Built in schema better be valid");
29+
let schema = Validator::new(&schema_json).expect("Built in schema better be valid");
3030
Self { schema }
3131
}
3232

0 commit comments

Comments
 (0)