pub struct JwtEncoder {
pub encoding_key: HashMap<String, (EncodingKey, Algorithm)>,
/* private fields */
}Fields§
§encoding_key: HashMap<String, (EncodingKey, Algorithm)>用于签发 JWT 的密钥。从 kid 到 (EncodingKey, Algorithm) 的映射
Implementations§
Source§impl JwtEncoder
impl JwtEncoder
pub fn new(encoding_key: HashMap<String, (EncodingKey, Algorithm)>) -> Self
Sourcepub fn encode<P: Serialize>(
&self,
claims: &Jwt<P>,
kid: &str,
) -> Result<String, AuthError>
pub fn encode<P: Serialize>( &self, claims: &Jwt<P>, kid: &str, ) -> Result<String, AuthError>
§将 JWT 声明编码为字符串形式的 Token
注意:header 中的 alg 字段和 kid 对应的加密算法需要保持一致
pub fn encode_randomly<P: Serialize>( &self, claims: &Jwt<P>, ) -> Result<String, AuthError>
Trait Implementations§
Source§impl Clone for JwtEncoder
impl Clone for JwtEncoder
Source§fn clone(&self) -> JwtEncoder
fn clone(&self) -> JwtEncoder
Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source. Read moreAuto Trait Implementations§
impl Freeze for JwtEncoder
impl RefUnwindSafe for JwtEncoder
impl Send for JwtEncoder
impl Sync for JwtEncoder
impl Unpin for JwtEncoder
impl UnsafeUnpin for JwtEncoder
impl UnwindSafe for JwtEncoder
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