pub struct Jwt { /* private fields */ }Expand description
JWT representation
Implementations§
Source§impl Jwt
impl Jwt
Sourcepub fn init(
algorithm: &str,
access_lifetime: i64,
refresh_lifetime: i64,
secret: Option<&str>,
private_key: Option<&str>,
public_key: Option<&str>,
) -> Result<Self, JwtError>
pub fn init( algorithm: &str, access_lifetime: i64, refresh_lifetime: i64, secret: Option<&str>, private_key: Option<&str>, public_key: Option<&str>, ) -> Result<Self, JwtError>
Initialize a new Jwt
Sourcepub fn access_lifetime(&self) -> i64
pub fn access_lifetime(&self) -> i64
Get access token lifetime
Sourcepub fn refresh_lifetime(&self) -> i64
pub fn refresh_lifetime(&self) -> i64
Get refresh token lifetime
Sourcepub fn set_access_lifetime(&mut self, duration: i64)
pub fn set_access_lifetime(&mut self, duration: i64)
Update access token lifetime (in minute)
Sourcepub fn set_refresh_lifetime(&mut self, duration: i64)
pub fn set_refresh_lifetime(&mut self, duration: i64)
Update refresh token lifetime (in day)
Sourcepub fn generate<P: Debug + Serialize>(
&self,
payload: P,
expired_at: UtcDateTime,
) -> Result<AccessToken, JwtError>
pub fn generate<P: Debug + Serialize>( &self, payload: P, expired_at: UtcDateTime, ) -> Result<AccessToken, JwtError>
Generate JWT
Sourcepub fn parse<P: Clone + Debug + for<'de> Deserialize<'de>>(
&self,
token: &AccessToken,
) -> Result<P, JwtError>
pub fn parse<P: Clone + Debug + for<'de> Deserialize<'de>>( &self, token: &AccessToken, ) -> Result<P, JwtError>
Parse JWT
Trait Implementations§
Auto Trait Implementations§
impl Freeze for Jwt
impl RefUnwindSafe for Jwt
impl Send for Jwt
impl Sync for Jwt
impl Unpin for Jwt
impl UnsafeUnpin for Jwt
impl UnwindSafe for Jwt
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