pub struct ClaimPath(/* private fields */);vc only.Expand description
A path into a JSON payload: a non-empty list of property names, array indexes and null
(every element).
SD-JWT VC §5.6.1 uses it as the path of claim metadata, where it names the claim as if
everything were disclosed; OID4VP §7 defines the same construct as the claims path pointer
of DCQL claims[].path, for every JSON-based credential format (jwt_vc_json and
dc+sd-jwt alike). ISO mdoc paths, which OID4VP §7 defines differently, are out of scope.
§Examples
use identity_kit::vc::ClaimPath;
use serde_json::json;
// SD-JWT VC §5.6.1.1 and OID4VP §7.
let credential = json!({
"name": "Arthur Dent",
"address": { "street_address": "42 Market Street", "city": "Milliways" },
"degrees": [
{ "type": "Bachelor of Science", "university": "University of Betelgeuse" },
{ "type": "Master of Science", "university": "University of Betelgeuse" }
],
"nationalities": ["British", "Betelgeusian"]
});
let path: ClaimPath = serde_json::from_value(json!(["degrees", null, "type"]))?;
assert_eq!(
path.select(&credential)?,
vec![&json!("Bachelor of Science"), &json!("Master of Science")]
);
let street = ClaimPath::new(["address", "street_address"]);
assert_eq!(street.select(&credential)?, vec![&json!("42 Market Street")]);
assert!(ClaimPath::new(["name", "first"]).select(&credential).is_err());Implementations§
Source§impl ClaimPath
impl ClaimPath
Sourcepub fn new<I, C>(components: I) -> Self
pub fn new<I, C>(components: I) -> Self
The path through components: &str names, usize indexes and () for every
element.
Sourcepub fn components(&self) -> &[PathComponent]
pub fn components(&self) -> &[PathComponent]
The components.
Sourcepub fn is_concrete(&self) -> bool
pub fn is_concrete(&self) -> bool
Whether every component names one element: no null.
Sourcepub fn matches(&self, path: &ClaimPath) -> bool
pub fn matches(&self, path: &ClaimPath) -> bool
Whether this path, which may contain null components, covers the concrete path.
Sourcepub fn is_prefix_of(&self, path: &ClaimPath) -> bool
pub fn is_prefix_of(&self, path: &ClaimPath) -> bool
Whether this path, which may contain null components, covers the concrete path or
one of its ancestors.
Sourcepub fn join(&self, component: impl Into<PathComponent>) -> Self
pub fn join(&self, component: impl Into<PathComponent>) -> Self
This path with component appended.
Sourcepub fn select<'a>(
&self,
root: &'a Value,
) -> Result<Vec<&'a Value>, ClaimPathError>
pub fn select<'a>( &self, root: &'a Value, ) -> Result<Vec<&'a Value>, ClaimPathError>
The values the path selects in root, per the processing rules of SD-JWT VC §5.6.1.2:
empty when a name or an index does not exist.
§Errors
ClaimPathError when a component meets a value of the wrong kind: a name against a
non-object, an index or null against a non-array.
Trait Implementations§
Source§impl<'de> Deserialize<'de> for ClaimPath
impl<'de> Deserialize<'de> for ClaimPath
Source§fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
impl Eq for ClaimPath
Source§impl From<Vec<PathComponent>> for ClaimPath
impl From<Vec<PathComponent>> for ClaimPath
Source§fn from(components: Vec<PathComponent>) -> Self
fn from(components: Vec<PathComponent>) -> Self
Source§impl<C: Into<PathComponent>> FromIterator<C> for ClaimPath
impl<C: Into<PathComponent>> FromIterator<C> for ClaimPath
Source§fn from_iter<I: IntoIterator<Item = C>>(iter: I) -> Self
fn from_iter<I: IntoIterator<Item = C>>(iter: I) -> Self
Source§impl PartialSchema for ClaimPath
Available on crate feature utoipa only.
impl PartialSchema for ClaimPath
utoipa only.impl StructuralPartialEq for ClaimPath
Auto Trait Implementations§
impl Freeze for ClaimPath
impl RefUnwindSafe for ClaimPath
impl Send for ClaimPath
impl Sync for ClaimPath
impl Unpin for ClaimPath
impl UnsafeUnpin for ClaimPath
impl UnwindSafe for ClaimPath
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> DeserializeOwned for Twhere
T: for<'de> Deserialize<'de>,
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
key and return true if they are equal.