pub struct JwtBuilder { /* private fields */ }Expand description
JWT 构建器
使用 Builder 模式创建 JWT token
Implementations§
Source§impl JwtBuilder
impl JwtBuilder
Sourcepub fn expires_in_seconds(self, seconds: i64) -> Self
pub fn expires_in_seconds(self, seconds: i64) -> Self
设置过期时间(秒数,从现在开始)
Sourcepub fn expires_in_minutes(self, minutes: i64) -> Self
pub fn expires_in_minutes(self, minutes: i64) -> Self
设置过期时间(分钟数,从现在开始)
Sourcepub fn expires_in_hours(self, hours: i64) -> Self
pub fn expires_in_hours(self, hours: i64) -> Self
设置过期时间(小时数,从现在开始)
Sourcepub fn expires_in_days(self, days: i64) -> Self
pub fn expires_in_days(self, days: i64) -> Self
设置过期时间(天数,从现在开始)
Sourcepub fn expires_in(self, duration: Duration) -> Self
pub fn expires_in(self, duration: Duration) -> Self
设置过期时间(Duration)
Sourcepub fn not_before(self, nbf: i64) -> Self
pub fn not_before(self, nbf: i64) -> Self
设置生效时间(Not Before)
Sourcepub fn not_before_in_seconds(self, seconds: i64) -> Self
pub fn not_before_in_seconds(self, seconds: i64) -> Self
设置延迟生效(秒数,从现在开始)
Sourcepub fn with_random_jwt_id(self) -> Self
pub fn with_random_jwt_id(self) -> Self
自动生成 JWT ID
Sourcepub fn algorithm(self, algorithm: JwtAlgorithm) -> Self
pub fn algorithm(self, algorithm: JwtAlgorithm) -> Self
设置算法
Sourcepub fn build_with_secret(self, secret: &[u8]) -> Result<String>
pub fn build_with_secret(self, secret: &[u8]) -> Result<String>
Sourcepub fn build_with_rsa_private_key(
self,
private_key_pem: &[u8],
) -> Result<String>
pub fn build_with_rsa_private_key( self, private_key_pem: &[u8], ) -> Result<String>
Sourcepub fn build_with_ec_private_key(self, private_key_pem: &[u8]) -> Result<String>
pub fn build_with_ec_private_key(self, private_key_pem: &[u8]) -> Result<String>
Sourcepub fn get_claims(&self) -> &Claims
pub fn get_claims(&self) -> &Claims
获取 claims 引用(用于调试)
Trait Implementations§
Source§impl Clone for JwtBuilder
impl Clone for JwtBuilder
Source§fn clone(&self) -> JwtBuilder
fn clone(&self) -> JwtBuilder
Returns a duplicate of the value. Read more
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source. Read moreSource§impl Debug for JwtBuilder
impl Debug for JwtBuilder
Source§impl Default for JwtBuilder
impl Default for JwtBuilder
Source§fn default() -> JwtBuilder
fn default() -> JwtBuilder
Returns the “default value” for a type. Read more
Auto Trait Implementations§
impl Freeze for JwtBuilder
impl RefUnwindSafe for JwtBuilder
impl Send for JwtBuilder
impl Sync for JwtBuilder
impl Unpin for JwtBuilder
impl UnwindSafe for JwtBuilder
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more