| Crates.io | sa-token-adapter |
| lib.rs | sa-token-adapter |
| version | 0.1.12 |
| created_at | 2025-10-11 02:41:57.011545+00 |
| updated_at | 2025-12-17 04:47:55.310665+00 |
| description | Adapter traits for sa-token-rust framework integration |
| homepage | https://github.com/llc-993/sa-token-rust |
| repository | https://github.com/llc-993/sa-token-rust |
| max_upload_size | |
| id | 1877771 |
| size | 24,086 |
Adapter layer for sa-token-rust framework integration.
[dependencies]
sa-token-adapter = "0.1.12"
async-trait = "0.1"
Storage interface for tokens and sessions:
#[async_trait]
pub trait SaStorage: Send + Sync {
async fn get(&self, key: &str) -> StorageResult<Option<String>>;
async fn set(&self, key: &str, value: &str, ttl: Option<Duration>) -> StorageResult<()>;
async fn delete(&self, key: &str) -> StorageResult<()>;
// ... more methods
}
HTTP request/response abstraction:
pub trait SaRequest {
fn get_header(&self, name: &str) -> Option<String>;
fn get_cookie(&self, name: &str) -> Option<String>;
fn get_param(&self, name: &str) -> Option<String>;
}
pub trait SaResponse {
fn set_header(&mut self, name: &str, value: &str);
fn set_cookie(&mut self, cookie: SaCookie);
fn set_status(&mut self, status: u16);
}
use sa_token_adapter::storage::{SaStorage, StorageResult};
use async_trait::async_trait;
pub struct MyStorage {
// Your storage fields
}
#[async_trait]
impl SaStorage for MyStorage {
async fn get(&self, key: &str) -> StorageResult<Option<String>> {
// Your implementation
}
// Implement other required methods...
}
金书记
Licensed under either of: