Skip to content

Commit 4b37a10

Browse files
committed
Add Clone bound for decode
Closes #432
1 parent ac10042 commit 4b37a10

File tree

4 files changed

+6
-4
lines changed

4 files changed

+6
-4
lines changed

CHANGELOG.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,8 @@
22

33
## 10.0.0 (unreleased)
44

5-
- Introduce alternative crypto backends (AWS-LC, RustCrypto)
5+
- BREAKING: use traits for crypto backends, you have to choose between `aws_lc_rs` and `rust_crypto`
6+
- Add `Clone` bound to `decode`
67

78
## 9.3.1 (2024-02-06)
89

Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[package]
22
name = "jsonwebtoken"
3-
version = "9.3.1"
3+
version = "10.0.0"
44
authors = ["Vincent Prouillet <hello@vincentprouillet.com>"]
55
license = "MIT"
66
readme = "README.md"

README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ See [JSON Web Tokens](https://en.wikipedia.org/wiki/JSON_Web_Token) for more inf
88
Add the following to Cargo.toml:
99

1010
```toml
11+
# You will have to select either `aws_lc_rs` or `rust_crypto` as backend if you're not using your own
1112
jsonwebtoken = { version = "10", features = ["aws_lc_rs"] }
1213
# If you do not need pem decoding, you can disable the default feature `use_pem` that way:
1314
# jsonwebtoken = {version = "10", default-features = false, features = ["aws_lc_rs"] }

src/decoding.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -259,7 +259,7 @@ impl DecodingKey {
259259
/// use serde::{Deserialize, Serialize};
260260
/// use jsonwebtoken::{decode, DecodingKey, Validation, Algorithm};
261261
///
262-
/// #[derive(Debug, Serialize, Deserialize)]
262+
/// #[derive(Debug, Clone, Serialize, Deserialize)]
263263
/// struct Claims {
264264
/// sub: String,
265265
/// company: String
@@ -269,7 +269,7 @@ impl DecodingKey {
269269
/// // Claims is a struct that implements Deserialize
270270
/// let token_message = decode::<Claims>(&token, &DecodingKey::from_secret("secret".as_ref()), &Validation::new(Algorithm::HS256));
271271
/// ```
272-
pub fn decode<T: DeserializeOwned>(
272+
pub fn decode<T: DeserializeOwned + Clone>(
273273
token: &str,
274274
key: &DecodingKey,
275275
validation: &Validation,

0 commit comments

Comments
 (0)