chore: Update jsonschema

This commit is contained in:
Gerald Pinder 2025-01-01 22:05:05 -05:00
parent 99369ca588
commit f6655d00ee
3 changed files with 29 additions and 55 deletions

12
Cargo.lock generated
View file

@ -729,7 +729,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "117725a109d387c937a1533ce01b450cbde6b88abceea8473c4d7a85853cda3c"
dependencies = [
"lazy_static",
"windows-sys 0.48.0",
"windows-sys 0.59.0",
]
[[package]]
@ -2157,9 +2157,9 @@ dependencies = [
[[package]]
name = "jsonschema"
version = "0.26.2"
version = "0.28.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "26a960f0c34d5423581d858ce94815cc11f0171b09939409097969ed269ede1b"
checksum = "c2303ef9ebb6acd7afe7c48cbc06ab807349c429d4e47c4cde8b35400503198f"
dependencies = [
"ahash 0.8.11",
"base64 0.22.1",
@ -3476,9 +3476,9 @@ dependencies = [
[[package]]
name = "referencing"
version = "0.26.2"
version = "0.28.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "fb8e15af8558cb157432dd3d88c1d1e982d0a5755cf80ce593b6499260aebc49"
checksum = "2fb7a1f338d8e32357ad1d7078454c248e5fdd2188fbb6966b400c2fa4d4f566"
dependencies = [
"ahash 0.8.11",
"fluent-uri",
@ -5278,7 +5278,7 @@ version = "0.1.9"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "cf221c93e13a30d793f7645a0e7762c55d169dbb0a49671918a2319d289b10bb"
dependencies = [
"windows-sys 0.48.0",
"windows-sys 0.59.0",
]
[[package]]

View file

@ -70,7 +70,7 @@ blue-build-process-management = { version = "=0.9.1", path = "./process" }
clap-verbosity-flag = "3"
clap_complete = "4"
fuzzy-matcher = "0.3"
jsonschema = { version = "0.26", optional = true }
jsonschema = { version = "0.28", optional = true }
open = "5"
os_info = "3"
rayon = { version = "1", optional = true }

View file

@ -1,31 +1,37 @@
use std::sync::Arc;
use jsonschema::paths::{LazyLocation, Location as JsonLocation};
use jsonschema::paths::{LazyLocation, Location as JsonLocation, LocationSegment};
#[derive(Debug, Default, Clone, PartialEq, Eq)]
pub struct Location(JsonLocation);
#[derive(Debug, Default, Clone, Hash, PartialEq, Eq)]
pub struct Location(Arc<String>);
impl std::ops::Deref for Location {
type Target = JsonLocation;
impl Location {
pub fn as_str(&self) -> &str {
self.0.as_str()
fn deref(&self) -> &Self::Target {
&self.0
}
}
impl From<&JsonLocation> for Location {
fn from(value: &JsonLocation) -> Self {
Self(Arc::new(value.as_str().into()))
impl std::ops::DerefMut for Location {
fn deref_mut(&mut self) -> &mut Self::Target {
&mut self.0
}
}
impl std::hash::Hash for Location {
fn hash<H: std::hash::Hasher>(&self, state: &mut H) {
self.0.as_str().hash(state);
}
}
impl From<JsonLocation> for Location {
fn from(value: JsonLocation) -> Self {
Self(Arc::new(value.as_str().into()))
Self(value)
}
}
impl std::fmt::Display for Location {
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
write!(f, "{}", &self.0)
impl From<&JsonLocation> for Location {
fn from(value: &JsonLocation) -> Self {
Self(value.clone())
}
}
@ -38,7 +44,7 @@ impl TryFrom<&str> for Location {
I: Iterator<Item = &'c str>,
{
let Some(path) = path_iter.next() else {
return JsonLocation::from(location).into();
return Location(JsonLocation::from(location));
};
let location = build(path, location);
child(path_iter, &location)
@ -61,7 +67,7 @@ impl TryFrom<&str> for Location {
}
let Some(path) = path_iter.next() else {
return Ok(Self::from(JsonLocation::from(&LazyLocation::new())));
return Ok(Self(JsonLocation::from(&LazyLocation::new())));
};
let location = LazyLocation::new();
@ -86,35 +92,3 @@ impl TryFrom<String> for Location {
Self::try_from(value.as_str())
}
}
pub struct LocationSegmentIterator<'a> {
iter: std::vec::IntoIter<LocationSegment<'a>>,
}
impl<'a> Iterator for LocationSegmentIterator<'a> {
type Item = LocationSegment<'a>;
fn next(&mut self) -> Option<Self::Item> {
self.iter.next()
}
}
impl<'a> IntoIterator for &'a Location {
type Item = LocationSegment<'a>;
type IntoIter = LocationSegmentIterator<'a>;
fn into_iter(self) -> Self::IntoIter {
Self::IntoIter {
iter: self
.as_str()
.split('/')
.filter(|p| !p.is_empty())
.map(|p| {
p.parse::<usize>()
.map_or_else(|_| LocationSegment::Property(p), LocationSegment::Index)
})
.collect::<Vec<_>>()
.into_iter(),
}
}
}