🔐 Embedded Rust Power Modules
RustAPI embeds high-speed security primitives directly into compiled Rust binary extensions, eliminating Python package dependencies like PyJWT or passlib.
1. Native JWT Engine (jsonwebtoken crate)
import rustapi
# Encode JSON Web Tokens natively in Rust
token = rustapi.encode_jwt(
claims={"sub": "user_100", "role": "admin"},
secret="secret_key_123",
algorithm="HS256"
)
# Decode and validate tokens in Rust
claims = rustapi.decode_jwt(token, secret="secret_key_123", algorithm="HS256")
print(claims["sub"]) # "user_100"
🛡️ High-Speed Password Hashing (Argon2)
Hash and verify user passwords using compiled Rust Argon2 implementations executing on background Tokio worker pools:
import rustapi
# Hash password with secure random salt
hashed = rustapi.hash_password("super_secret_password")
# Verify password against hash
valid = rustapi.verify_password("super_secret_password", hashed)
print(valid) # True
🎨 MiniJinja Template Renderer
Render Jinja2-compatible HTML templates natively inside Rust memory without Jinja2 Python package overhead:
import rustapi
@app.get("/welcome")
def welcome():
html = rustapi.render_template(
"<h1>Welcome {{ name }}!</h1><p>Active items: {{ items | length }}</p>",
{"name": "Boopathi", "items": ["A", "B", "C"]}
)
return rustapi.HTMLResponse(html)