# PWT — Protobuf Web Token (Rust)
**PWT** (Protobuf Web Token) stores JWT-style claims in Protocol Buffers.
It mirrors the Go implementation and uses the same signing algorithms.
Tokens are smaller than JSON JWTs, and parsing is faster thanks to protobuf
serialization. Custom data lives in a protobuf `Struct` payload.
---
## Why PWT?
- ✅ **Smaller tokens** via protobuf serialization
- 🚀 **Faster parse + verify** routines
- 🔒 Uses JWT-compatible signing algorithms (HS256, RS256, EdDSA)
- 🔁 Drop-in JWT-style workflow with typed claims
---
## Installation
```bash
cargo add pwt-rust
```
The library is imported as `pwt`:
```rust
use pwt::{Token, TokenBody};
```
PWT is currently in initial development. Releases in the `0.x` series may
include documented API changes before the public API is stabilized at `1.0.0`.
---
## Quick Start
```rust
use pwt::{Key, SigningMethodHS256, Token, TokenBody};
use prost_types::Struct;
let mut body = TokenBody::default();
body.iss = "example".to_string();
body.sub = "user-123".to_string();
body.exp = 1_700_000_000;
let mut payload = Struct::default();
payload.fields.insert(
"role".to_string(),
prost_types::Value {
kind: Some(prost_types::value::Kind::StringValue("admin".to_string())),
},
);
body.payload = Some(payload);
let token = Token::new_with_claims(SigningMethodHS256::new(), body);
let token_str = token.signed_string(&Key::from_bytes("secret"))?;
development workflow and [SECURITY.md](SECURITY.md) for reporting security
issues.
---
## License
Licensed under the [MIT License](LICENSE).