File tree Expand file tree Collapse file tree 1 file changed +6
-4
lines changed Expand file tree Collapse file tree 1 file changed +6
-4
lines changed Original file line number Diff line number Diff 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
125127The generic parameter in ` Jws<C> ` indicates the claims type and prevents accidentally encoding or decoding the wrong claims type
126128when the Jws is nested in another struct.
You can’t perform that action at this time.
0 commit comments