Skip to content

Commit 3076276

Browse files
committed
Rename Claim::claim to Claim::value
1 parent 63a47aa commit 3076276

File tree

1 file changed

+10
-10
lines changed

1 file changed

+10
-10
lines changed

crates/jose/src/claims.rs

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ impl<T> Validator<T> for () {
4949
}
5050

5151
pub struct Claim<T, V = ()> {
52-
claim: &'static str,
52+
value: &'static str,
5353
t: PhantomData<T>,
5454
v: PhantomData<V>,
5555
}
@@ -61,7 +61,7 @@ where
6161
#[must_use]
6262
pub const fn new(claim: &'static str) -> Self {
6363
Self {
64-
claim,
64+
value: claim,
6565
t: PhantomData,
6666
v: PhantomData,
6767
}
@@ -83,8 +83,8 @@ where
8383
{
8484
let value = value.into();
8585
let value: serde_json::Value =
86-
serde_json::to_value(&value).map_err(|_| ClaimError::InvalidClaim(self.claim))?;
87-
claims.insert(self.claim.to_owned(), value);
86+
serde_json::to_value(&value).map_err(|_| ClaimError::InvalidClaim(self.value))?;
87+
claims.insert(self.value.to_owned(), value);
8888

8989
Ok(())
9090
}
@@ -126,15 +126,15 @@ where
126126
{
127127
let validator: V = validator.into();
128128
let claim = claims
129-
.remove(self.claim)
130-
.ok_or(ClaimError::MissingClaim(self.claim))?;
129+
.remove(self.value)
130+
.ok_or(ClaimError::MissingClaim(self.value))?;
131131

132132
let res =
133-
serde_json::from_value(claim).map_err(|_| ClaimError::InvalidClaim(self.claim))?;
133+
serde_json::from_value(claim).map_err(|_| ClaimError::InvalidClaim(self.value))?;
134134
validator
135135
.validate(&res)
136136
.map_err(|source| ClaimError::ValidationError {
137-
claim: self.claim,
137+
claim: self.value,
138138
source: Box::new(source),
139139
})?;
140140
Ok(res)
@@ -192,8 +192,8 @@ where
192192
&self,
193193
claims: &HashMap<String, serde_json::Value>,
194194
) -> Result<(), ClaimError> {
195-
if claims.contains_key(self.claim) {
196-
Err(ClaimError::InvalidClaim(self.claim))
195+
if claims.contains_key(self.value) {
196+
Err(ClaimError::InvalidClaim(self.value))
197197
} else {
198198
Ok(())
199199
}

0 commit comments

Comments
 (0)