pub struct Key {
pub algorithm: Algorithm,
pub operations: HashSet<KeyOperation>,
pub secret: Vec<u8>,
pub kid: Option<String>,
/* private fields */
}
Expand description
Similar to JWK but not quite the same because it’s annoying to implement.
Fields§
§algorithm: Algorithm
The algorithm used by the key.
operations: HashSet<KeyOperation>
The operations that the key can perform.
secret: Vec<u8>
The secret key as base64url (unpadded).
kid: Option<String>
The key ID, useful for rotating keys.
Implementations§
Source§impl Key
impl Key
pub fn from_str(s: &str) -> Result<Self>
pub fn from_file<P: AsRef<StdPath>>(path: P) -> Result<Self>
pub fn to_str(&self) -> Result<String>
pub fn to_file<P: AsRef<StdPath>>(&self, path: P) -> Result<()>
pub fn decode(&self, token: &str) -> Result<Claims>
pub fn encode(&self, payload: &Claims) -> Result<String>
Trait Implementations§
Source§impl<'de> Deserialize<'de> for Key
impl<'de> Deserialize<'de> for Key
Source§fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
Deserialize this value from the given Serde deserializer. Read more
Auto Trait Implementations§
impl !Freeze for Key
impl RefUnwindSafe for Key
impl Send for Key
impl Sync for Key
impl Unpin for Key
impl UnwindSafe for Key
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