feat(pointer): JsonPointee impl for uuid::Uuid

Adds feature-gated `JsonPointee` and `JsonPointerTarget`
impls for `uuid::Uuid` in `ploidy-pointer`, mirroring the
existing impls for `chrono::DateTime<Utc>` and `url::Url`.

`ploidy-util` enables the new feature, so generated client
code can resolve JSON Pointers through `Uuid` fields the same
way it already does for `String`, `i64`, etc.
This commit is contained in:
C J Silverio
2026-05-20 19:56:34 -07:00
committed by Lina Butler
parent a2e4f564ff
commit 0f1fbb9209
5 changed files with 29 additions and 0 deletions
Generated
+1
View File
@@ -1184,6 +1184,7 @@ dependencies = [
"strsim",
"thiserror 2.0.18",
"url",
"uuid",
]
[[package]]
+8
View File
@@ -31,6 +31,12 @@ default-features = false
features = []
optional = true
[dependencies.uuid]
version = "1"
default-features = false
features = []
optional = true
[features]
default = ["derive"]
full = [
@@ -42,6 +48,7 @@ full = [
"serde_bytes",
"serde_json",
"url",
"uuid",
]
chrono = ["dep:chrono"]
derive = ["dep:ploidy-pointer-derive"]
@@ -51,3 +58,4 @@ serde = ["dep:serde"]
serde_bytes = ["dep:serde_bytes"]
serde_json = ["dep:serde_json"]
url = ["dep:url"]
uuid = ["dep:uuid"]
+2
View File
@@ -324,6 +324,7 @@ impl_pointee_for!(
#[cfg(feature = "chrono")] chrono::DateTime<chrono::Utc>,
#[cfg(feature = "chrono")] chrono::NaiveDate,
#[cfg(feature = "url")] url::Url,
#[cfg(feature = "uuid")] uuid::Uuid,
#[cfg(feature = "serde_bytes")] serde_bytes::ByteBuf,
);
@@ -353,6 +354,7 @@ impl_copied_pointer_target_for!(
i8, u8, i16, u16, i32, u32, i64, u64, i128, u128, isize, usize, f32, f64, bool,
#[cfg(feature = "chrono")] chrono::DateTime<chrono::Utc>,
#[cfg(feature = "chrono")] chrono::NaiveDate,
#[cfg(feature = "uuid")] uuid::Uuid,
);
#[cfg(feature = "serde_bytes")]
+17
View File
@@ -464,6 +464,23 @@ fn test_pointer_to_url() {
assert!(url.resolve(pointer).is_err());
}
#[test]
#[cfg(feature = "uuid")]
fn test_pointer_to_uuid() {
use uuid::Uuid;
let id = Uuid::nil();
// Empty pointer should return the UUID itself.
let pointer = JsonPointer::parse("").unwrap();
let result = id.resolve(pointer).unwrap() as &dyn Any;
assert_eq!(result.downcast_ref::<Uuid>(), Some(&id));
// Non-empty pointer should fail.
let pointer = JsonPointer::parse("/foo").unwrap();
assert!(id.resolve(pointer).is_err());
}
#[test]
#[cfg(feature = "serde_json")]
fn test_pointer_to_serde_json() {
+1
View File
@@ -22,6 +22,7 @@ ploidy-pointer = { workspace = true, features = [
"serde_bytes",
"serde_json",
"url",
"uuid",
] }
reqwest = { version = "0.13", default-features = false, features = [
"form",