pub struct Tokens { /* private fields */ }Expand description
Tokens interface for creating and validating tokens
Implementations§
Source§impl Tokens
impl Tokens
Sourcepub fn new(secret: &[u8]) -> Self
pub fn new(secret: &[u8]) -> Self
Creates a new tokens interface from the provided secret key
secret The secret key
Sourcepub fn encode<T: Serialize>(&self, claims: &T) -> Result<String, JsonError>
pub fn encode<T: Serialize>(&self, claims: &T) -> Result<String, JsonError>
Encodes the provided claims into a token returning the encoded token
claims The claims to encode
Sourcepub fn decode<T: DeserializeOwned>(&self, token: &str) -> Result<T, DecodeError>
pub fn decode<T: DeserializeOwned>(&self, token: &str) -> Result<T, DecodeError>
Decodes a token claims from the provided token string
token The token to decode
Auto Trait Implementations§
impl Freeze for Tokens
impl RefUnwindSafe for Tokens
impl Send for Tokens
impl Sync for Tokens
impl Unpin for Tokens
impl UnwindSafe for Tokens
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