pub fn encode_token(header: &Header, id: String, key: &EncodingKey) -> StringExpand description
Encodes user information into a JSON Web Token (JWT).
This function creates a new JWT with the provided user ID as the subject,
sets the issued-at and expiration times (60 minutes from now), and signs it
using the given encoding key. The resulting token is a serialized Claims.
§Arguments
header: The JWT header, specifying the algorithm (e.g., HS256).id: The user ID (String) to be embedded as the subject (sub) claim.key: TheEncodingKeyused to sign the JWT.
§Returns
A String representing the encoded JWT containing Claims.
§Panics
Panics if the token encoding fails for any reason (e.g., invalid key).