pub struct Key {
pub algorithm: Algorithm,
pub operations: HashSet<KeyOperation>,
pub key: KeyType,
pub kid: Option<KeyId>,
/* private fields */
}Expand description
JWK, almost to spec (https://datatracker.ietf.org/doc/html/rfc7517) but not quite the same because it’s annoying to implement.
Fields§
§algorithm: AlgorithmThe algorithm used by the key.
operations: HashSet<KeyOperation>The operations that the key can perform.
key: KeyTypeDefaults to KeyType::OCT
kid: Option<KeyId>The key ID, useful for rotating keys.
Implementations§
Source§impl<'de> Key
impl<'de> Key
pub fn deserialize<__D>(__deserializer: __D) -> Result<Key, __D::Error>where
__D: Deserializer<'de>,
Source§impl Key
impl Key
Sourcepub fn from_str(s: &str) -> Result<Self>
pub fn from_str(s: &str) -> Result<Self>
Parse a key from a string, auto-detecting JSON or base64url encoding.
Sourcepub fn from_file<P: AsRef<StdPath>>(path: P) -> Result<Self>
pub fn from_file<P: AsRef<StdPath>>(path: P) -> Result<Self>
Load a key from a file, auto-detecting JSON or base64url encoding.
Sourcepub fn to_file<P: AsRef<StdPath>>(&self, path: P) -> Result<()>
pub fn to_file<P: AsRef<StdPath>>(&self, path: P) -> Result<()>
Write the key to a file as base64url-encoded JSON.
pub fn to_public(&self) -> Result<Self>
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 UnsafeUnpin 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