| Crates.io | token-claims |
| lib.rs | token-claims |
| version | 0.1.1 |
| created_at | 2025-06-07 21:58:48.287032+00 |
| updated_at | 2025-06-07 22:06:33.179218+00 |
| description | A Rust library for ergonomic handling of JWT claims with strong typing and builder support. |
| homepage | |
| repository | https://github.com/oblivisheee/token-claims |
| max_upload_size | |
| id | 1704444 |
| size | 34,927 |
A Rust library for ergonomic handling of JWT claims with strong typing and builder support.
TokenClaims<T> struct for custom or primitive claim types.msgpack feature).Subject<T>), timestamp (TimeStamp), and JWT ID (JWTID).use token_claims::{TokenClaimsBuilder, Subject, TimeStamp, JWTID};
#[derive(serde::Serialize, serde::Deserialize)]
struct MyClaims {
username: String,
admin: bool,
}
let claims = TokenClaimsBuilder::<MyClaims>::default()
.sub(Subject::new(MyClaims {
username: "alice".to_string(),
admin: true,
}))
.exp(TimeStamp::from_now(3600))
.iat(TimeStamp::from_now(0))
.typ("access".to_string())
.iss("issuer".to_string())
.aud("audience".to_string())
.jti(JWTID::new())
.build()
.unwrap();