Skip to content

Commit 9b3e19c

Browse files
authored
Fix function names in README (#457)
1 parent 655abeb commit 9b3e19c

File tree

1 file changed

+6
-4
lines changed

1 file changed

+6
-4
lines changed

README.md

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -113,14 +113,16 @@ something similar and reuse it.
113113

114114
### Encoding and decoding JWS
115115

116-
JWS is handled the same way as JWT, but using `encode_jws` and `decode_jws`:
116+
JWS is handled the same way as JWT, but using `jsonwebtoken::jws::encode` and `jsonwebtoken::jws::decode`:
117117

118118
```rust
119-
let encoded = encode_jws(&Header::default(), &my_claims, &EncodingKey::from_secret("secret".as_ref()))?;
120-
my_claims = decode_jws(&encoded, &DecodingKey::from_secret("secret".as_ref()), &Validation::default())?.claims;
119+
use jsonwebtoken::jws::{encode, decode};
120+
121+
let encoded = encode(&Header::default(), &my_claims, &EncodingKey::from_secret("secret".as_ref()))?;
122+
my_claims = decode(&encoded, &DecodingKey::from_secret("secret".as_ref()), &Validation::default())?.claims;
121123
```
122124

123-
`encode_jws` returns a `Jws<C>` struct which can be placed in other structs or serialized/deserialized from JSON directly.
125+
`jsonwebtoken::jws::encode` returns a `Jws<C>` struct which can be placed in other structs or serialized/deserialized from JSON directly.
124126

125127
The generic parameter in `Jws<C>` indicates the claims type and prevents accidentally encoding or decoding the wrong claims type
126128
when the Jws is nested in another struct.

0 commit comments

Comments
 (0)