Skip to main content

Key

Struct Key 

Source
pub struct Key { /* private fields */ }
Expand description

A JSON Web Key (RFC 7517).

Represents a single cryptographic key with its parameters and metadata.

§Examples

use jwk_simple::{Key, KeyType};

// Parse from JSON
let json = r#"{"kty":"RSA","n":"AQAB","e":"AQAB"}"#;
let jwk: Key = serde_json::from_str(json).unwrap();

// Check key properties
assert_eq!(jwk.kty(), KeyType::Rsa);
assert!(jwk.is_public_key_only());

Implementations§

Source§

impl Key

Source

pub fn is_web_crypto_compatible(&self) -> bool

Available on crate feature web-crypto and WebAssembly only.

Returns true if this key can be used with WebCrypto.

OKP keys and secp256k1 EC keys are not supported by WebCrypto.

§Examples
if key.is_web_crypto_compatible() {
    let crypto_key = key.import_as_verify_key_for_alg(&alg).await?;
}
Source

pub async fn import_as_verify_key(&self) -> Result<CryptoKey>

Available on crate feature web-crypto and WebAssembly only.

Imports this key as a CryptoKey for signature verification.

RSA and HMAC keys must have their alg field set. For keys without alg (common in JWKS from OIDC providers), use import_as_verify_key_for_alg instead.

§Errors
Source

pub async fn import_as_sign_key(&self) -> Result<CryptoKey>

Available on crate feature web-crypto and WebAssembly only.

Imports this key as a CryptoKey for signing.

RSA and HMAC keys must have their alg field set. For keys without alg, use import_as_sign_key_for_alg instead.

§Errors
Source

pub async fn import_as_encrypt_key(&self) -> Result<CryptoKey>

Available on crate feature web-crypto and WebAssembly only.

Imports this key as a CryptoKey for encryption.

§Errors
Source

pub async fn import_as_decrypt_key(&self) -> Result<CryptoKey>

Available on crate feature web-crypto and WebAssembly only.

Imports this key as a CryptoKey for decryption.

§Errors
Source

pub async fn import_as_verify_key_for_alg( &self, alg: &Algorithm, ) -> Result<CryptoKey>

Available on crate feature web-crypto and WebAssembly only.

Imports this key as a CryptoKey for signature verification with an explicit algorithm.

This is useful when the key’s alg field is absent (common in JWKS from OIDC providers). WebCrypto locks the hash algorithm at import time, so the algorithm must be known before importing. The alg parameter overrides the key’s own alg field.

§Errors
Source

pub async fn import_as_sign_key_for_alg( &self, alg: &Algorithm, ) -> Result<CryptoKey>

Available on crate feature web-crypto and WebAssembly only.

Imports this key as a CryptoKey for signing with an explicit algorithm.

This is useful when the key’s alg field is absent. See Key::import_as_verify_key_for_alg for more details.

§Errors
Source§

impl Key

Source

pub fn new(params: KeyParams) -> Self

Creates a new Key from key-type-specific parameters.

The key type is automatically derived from the KeyParams variant via the kty() accessor, which makes it impossible to construct a Key with a mismatched key type.

Use the with_* methods to set optional metadata fields:

§Examples
use jwk_simple::{Key, KeyType, KeyParams, RsaParams, KeyUse, Algorithm};
use jwk_simple::encoding::Base64UrlBytes;

let key = Key::new(KeyParams::Rsa(RsaParams::new_public(
    Base64UrlBytes::new(vec![1, 2, 3]),
    Base64UrlBytes::new(vec![1, 0, 1]),
)))
.with_kid("my-key-id")
.with_alg(Algorithm::Rs256)
.with_use(KeyUse::Signature);

assert_eq!(key.kty(), KeyType::Rsa);
assert_eq!(key.kid(), Some("my-key-id"));
Source

pub fn kty(&self) -> KeyType

Returns the key type, derived from the KeyParams variant.

This is always consistent with the key’s parameters:

Source

pub fn kid(&self) -> Option<&str>

Returns the key ID (kid), if present.

Source

pub fn key_use(&self) -> Option<&KeyUse>

Returns the intended key use (use), if present.

Source

pub fn key_ops(&self) -> Option<&[KeyOperation]>

Returns the permitted operations (key_ops), if present.

Source

pub fn alg(&self) -> Option<&Algorithm>

Returns the declared algorithm (alg), if present.

Source

pub fn params(&self) -> &KeyParams

Returns the key-type-specific parameters.

Source

pub fn x5c(&self) -> Option<&[String]>

Returns the X.509 certificate chain (x5c), if present.

Source

pub fn x5t(&self) -> Option<&str>

Returns the X.509 SHA-1 certificate thumbprint (x5t), if present.

Source

pub fn x5t_s256(&self) -> Option<&str>

Returns the X.509 SHA-256 certificate thumbprint (x5t#S256), if present.

Source

pub fn x5u(&self) -> Option<&str>

Returns the X.509 URL (x5u), if present.

Source

pub fn with_kid(self, kid: impl Into<String>) -> Self

Sets the key ID (kid).

Source

pub fn with_use(self, key_use: KeyUse) -> Self

Sets the intended use of the key (use).

Source

pub fn with_key_ops( self, key_ops: impl IntoIterator<Item = KeyOperation>, ) -> Self

Sets the permitted key operations (key_ops).

Source

pub fn with_alg(self, alg: Algorithm) -> Self

Sets the algorithm intended for use with the key (alg).

Source

pub fn with_x5c(self, x5c: Vec<String>) -> Self

Sets the X.509 certificate chain (x5c).

Source

pub fn with_x5t(self, x5t: impl Into<String>) -> Self

Sets the X.509 certificate SHA-1 thumbprint (x5t).

Source

pub fn with_x5t_s256(self, x5t_s256: impl Into<String>) -> Self

Sets the X.509 certificate SHA-256 thumbprint (x5t#S256).

Source

pub fn with_x5u(self, x5u: impl Into<String>) -> Self

Sets the X.509 URL (x5u).

Source

pub fn is_public_key_only(&self) -> bool

Returns true if this contains only public key parameters.

Source

pub fn has_private_key(&self) -> bool

Returns true if this contains private key parameters.

Source

pub fn validate(&self) -> Result<()>

Validates the JWK structure and metadata consistency.

This is a context-free structural check: it verifies the key material is well-formed, metadata fields are internally consistent, and X.509 fields are properly encoded and match the key material.

This method does not check algorithm suitability, key strength for a specific algorithm, or operation intent, even if the alg field is set on the key. A key with "alg": "RS256" on a symmetric key type passes validate() because the key material itself is structurally valid; the algorithm mismatch is a suitability concern. Use Key::validate_for_use for those checks.

In other words, validate() is the context-free gate: it validates the key’s own parameters and metadata (use, key_ops, x5u, x5c, x5t, x5t#S256) without deciding whether the key is acceptable for a particular algorithm or operation.

This method does not perform PKIX trust/path validation for x5c chains (trust anchors, validity period, key usage/EKU, revocation, etc.). PKIX trust validation is application-defined and out of scope for this crate.

Source

pub fn validate_for_use( &self, alg: &Algorithm, ops: impl IntoIterator<Item = KeyOperation>, ) -> Result<()>

Validates this key for a specific algorithm and operation(s).

This is the full pre-use gate: it performs structural validation (Key::validate) followed by algorithm suitability checks (type compatibility, key strength), algorithm-operation compatibility checks (requested operation is valid for the algorithm), operation capability checks (key material can actually perform the operation), and operation-intent enforcement (metadata permits the requested operations).

The alg parameter controls which algorithm constraints are applied (key type, minimum strength). If the key declares its own alg, it must match the requested algorithm. Unknown algorithms are rejected because suitability (type compatibility and strength) cannot be validated for them.

At least one operation must be provided. Passing an empty iterator returns an error (this is a caller precondition, not a key problem).

This method calls Key::validate internally, so callers do not need to call it separately.

This is the full pre-use gate for direct key use. It layers algorithm suitability, operation/algorithm compatibility, key-material capability, and operation intent on top of Key::validate.

§Examples
use jwk_simple::{Key, Algorithm, KeyOperation};

let json = r#"{"kty":"oct","k":"c2VjcmV0LWtleS1tYXRlcmlhbC10aGF0LWlzLWxvbmctZW5vdWdo"}"#;
let key: Key = serde_json::from_str(json).unwrap();

// Validate for HMAC signing
assert!(key.validate_for_use(&Algorithm::Hs256, [KeyOperation::Sign]).is_ok());
Source

pub fn check_operations_permitted( &self, operations: impl AsRef<[KeyOperation]>, ) -> Result<()>

Checks whether this key’s metadata permits the requested operation(s).

This enforces RFC 7517 operation-intent semantics:

  • If use is present, it must be compatible with all requested operations.
  • If key_ops is present, it must include all requested operations.
  • If both are present, they must be mutually consistent.
  • key_ops values must be unique.

Metadata members are optional in RFC 7517. If both use and key_ops are absent, this check succeeds.

At least one operation must be provided. Passing an empty slice returns an error (this is a caller precondition, not a key problem).

This does not perform key-material or algorithm-suitability checks. It does enforce use/key_ops metadata consistency (RFC 7517 §4.3), which may return Error::InvalidKey if the key’s own metadata is self-contradictory. Use Key::validate_for_use for the full pre-use gate.

§Examples
use jwk_simple::{Key, KeyOperation};

let json = r#"{"kty":"oct","use":"sig","k":"c2VjcmV0LWtleS1tYXRlcmlhbC10aGF0LWlzLWxvbmctZW5vdWdo"}"#;
let key: Key = serde_json::from_str(json).unwrap();

// Signing is permitted by use="sig"
assert!(key.check_operations_permitted(&[KeyOperation::Sign]).is_ok());

// Encryption is not permitted by use="sig"
assert!(key.check_operations_permitted(&[KeyOperation::Encrypt]).is_err());
Source

pub fn is_algorithm_compatible(&self, alg: &Algorithm) -> bool

Returns true if this key’s type (and curve, where applicable) is compatible with the given algorithm per RFC 7518.

This checks that the key type matches what the algorithm requires. For example, an RSA key is compatible with RS256 but not with ES256. For EC keys, the curve is also checked (e.g., P-256 for ES256).

Unknown algorithms always return false since their requirements cannot be determined.

§Examples
use jwk_simple::{Key, Algorithm};

let json = r#"{"kty":"RSA","n":"AQAB","e":"AQAB"}"#;
let key: Key = serde_json::from_str(json).unwrap();

assert!(key.is_algorithm_compatible(&Algorithm::Rs256));
assert!(!key.is_algorithm_compatible(&Algorithm::Es256));
Source

pub fn thumbprint(&self) -> String

Calculates the JWK thumbprint (RFC 7638).

The thumbprint is a base64url-encoded SHA-256 hash of the key’s required members.

Source

pub fn as_rsa(&self) -> Option<&RsaParams>

Returns the key as RSA parameters, if applicable.

Source

pub fn as_ec(&self) -> Option<&EcParams>

Returns the key as EC parameters, if applicable.

Source

pub fn as_symmetric(&self) -> Option<&SymmetricParams>

Returns the key as symmetric parameters, if applicable.

Source

pub fn as_okp(&self) -> Option<&OkpParams>

Returns the key as OKP parameters, if applicable.

Source

pub fn to_public(&self) -> Option<Key>

Extracts only the public key components, removing any private key material.

Public projection also normalizes key_ops to the subset that remains meaningful for a public key (verify, encrypt, wrapKey). Operations that require private or secret key material are removed.

For symmetric keys, this returns None since symmetric keys don’t have a separate public component.

§Examples
use jwk_simple::KeySet;

let json = r#"{"keys": [{
    "kty": "RSA",
    "n": "0vx7agoebGcQSuuPiLJXZptN9nndrQmbXEps2aiAFbWhM78LhWx4cbbfAAtVT86zwu1RK7aPFFxuhDR1L6tSoc_BJECPebWKRXjBZCiFV4n3oknjhMstn64tZ_2W-5JsGY4Hc5n9yBXArwl93lqt7_RN5w6Cf0h4QyQ5v-65YGjQR0_FDW2QvzqY368QQMicAtaSqzs8KJZgnYb9c7d0zgdAZHzu6qMQvRL5hajrn1n91CbOpbISD08qNLyrdkt-bFTWhAI4vMQFh6WeZu0fM4lFd2NcRwr3XPksINHaQ-G_xBniIqbw0Ls1jF44-csFCur-kEgU8awapJzKnqDKgw",
    "e": "AQAB",
    "d": "X4cTteJY_gn4FYPsXB8rdXix5vwsg1FLN5E3EaG6RJoVH-HLLKD9M7dx5oo7GURknchnrRweUkC7hT5fJLM0WbFAKNLWY2vv7B6NqXSzUvxT0_YSfqijwp3RTzlBaCxWp4doFk5N2o8Gy_nHNKroADIkJ46pRUohsXywbReAdYaMwFs9tv8d_cPVY3i07a3t8MN6TNwm0dSawm9v47UiCl3Sk5ZiG7xojPLu4sbg1U2jx4IBTNBznbJSzFHK66jT8bgkuqsk0GjskDJk19Z4qwjwbsnn4j2WBii3RL-Us2lGVkY8fkFzme1z0HbIkfz0Y6mqnOYtqc0X4jfcKoAC8Q"
}]}"#;
let jwks: KeySet = serde_json::from_str(json).unwrap();
let private_key = jwks.first().unwrap();

// Extract public key
let public_key = private_key.to_public().expect("RSA keys have public components");
assert!(public_key.is_public_key_only());

Trait Implementations§

Source§

impl Clone for Key

Source§

fn clone(&self) -> Key

Returns a duplicate of the value. Read more
1.0.0 · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for Key

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl<'de> Deserialize<'de> for Key

Source§

fn deserialize<D>(deserializer: D) -> Result<Self, D::Error>
where D: Deserializer<'de>,

Deserialize this value from the given Serde deserializer. Read more
Source§

impl Drop for Key

Source§

fn drop(&mut self)

Executes the destructor for this type. Read more
Source§

impl Hash for Key

Source§

fn hash<H: Hasher>(&self, state: &mut H)

Feeds this value into the given Hasher. Read more
1.3.0 · Source§

fn hash_slice<H>(data: &[Self], state: &mut H)
where H: Hasher, Self: Sized,

Feeds a slice of this type into the given Hasher. Read more
Source§

impl PartialEq for Key

Equality is based on the key type, key ID, use, operations, algorithm, and key material parameters. X.509 certificate fields (x5c, x5t, x5t#S256, x5u) are not compared, because two representations of the same cryptographic key may carry different certificate metadata.

§Security Note

This comparison is not constant-time. It uses short-circuit byte-by-byte comparison of key material, including private key components. Do not use == on Key values in security-sensitive decisions where one side is attacker-controlled, as timing differences may leak information about secret key material (CWE-208).

For constant-time comparison of symmetric key material, use SymmetricParams::ct_eq. For the underlying byte buffers, use Base64UrlBytes::ct_eq.

Source§

fn eq(&self, other: &Self) -> bool

Tests for self and other values to be equal, and is used by ==.
1.0.0 · Source§

fn ne(&self, other: &Rhs) -> bool

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
Source§

impl Serialize for Key

Source§

fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error>
where S: Serializer,

Serialize this value into the given Serde serializer. Read more
Source§

impl TryFrom<&Key> for ES256KeyPair

Available on crate feature jwt-simple only.
Source§

type Error = JwtSimpleKeyConversionError

The type returned in the event of a conversion error.
Source§

fn try_from(jwk: &Key) -> Result<Self, JwtSimpleKeyConversionError>

Performs the conversion.
Source§

impl TryFrom<&Key> for ES256PublicKey

Available on crate feature jwt-simple only.
Source§

type Error = JwtSimpleKeyConversionError

The type returned in the event of a conversion error.
Source§

fn try_from(jwk: &Key) -> Result<Self, JwtSimpleKeyConversionError>

Performs the conversion.
Source§

impl TryFrom<&Key> for ES256kKeyPair

Available on crate feature jwt-simple only.
Source§

type Error = JwtSimpleKeyConversionError

The type returned in the event of a conversion error.
Source§

fn try_from(jwk: &Key) -> Result<Self, JwtSimpleKeyConversionError>

Performs the conversion.
Source§

impl TryFrom<&Key> for ES256kPublicKey

Available on crate feature jwt-simple only.
Source§

type Error = JwtSimpleKeyConversionError

The type returned in the event of a conversion error.
Source§

fn try_from(jwk: &Key) -> Result<Self, JwtSimpleKeyConversionError>

Performs the conversion.
Source§

impl TryFrom<&Key> for ES384KeyPair

Available on crate feature jwt-simple only.
Source§

type Error = JwtSimpleKeyConversionError

The type returned in the event of a conversion error.
Source§

fn try_from(jwk: &Key) -> Result<Self, JwtSimpleKeyConversionError>

Performs the conversion.
Source§

impl TryFrom<&Key> for ES384PublicKey

Available on crate feature jwt-simple only.
Source§

type Error = JwtSimpleKeyConversionError

The type returned in the event of a conversion error.
Source§

fn try_from(jwk: &Key) -> Result<Self, JwtSimpleKeyConversionError>

Performs the conversion.
Source§

impl TryFrom<&Key> for Ed25519KeyPair

Available on crate feature jwt-simple only.
Source§

type Error = JwtSimpleKeyConversionError

The type returned in the event of a conversion error.
Source§

fn try_from(jwk: &Key) -> Result<Self, JwtSimpleKeyConversionError>

Performs the conversion.
Source§

impl TryFrom<&Key> for Ed25519PublicKey

Available on crate feature jwt-simple only.
Source§

type Error = JwtSimpleKeyConversionError

The type returned in the event of a conversion error.
Source§

fn try_from(jwk: &Key) -> Result<Self, JwtSimpleKeyConversionError>

Performs the conversion.
Source§

impl TryFrom<&Key> for HS256Key

Available on crate feature jwt-simple only.
Source§

fn try_from(jwk: &Key) -> Result<Self, JwtSimpleKeyConversionError>

§Errors

Returns JwtSimpleKeyConversionError::IncompatibleKey if key_ops is present but does not include both KeyOperation::Sign and KeyOperation::Verify. HS256Key in jwt-simple is bidirectional; callers that need one-directional HMAC usage should remove key_ops before converting.

Source§

type Error = JwtSimpleKeyConversionError

The type returned in the event of a conversion error.
Source§

impl TryFrom<&Key> for HS384Key

Available on crate feature jwt-simple only.
Source§

fn try_from(jwk: &Key) -> Result<Self, JwtSimpleKeyConversionError>

§Errors

Returns JwtSimpleKeyConversionError::IncompatibleKey if key_ops is present but does not include both KeyOperation::Sign and KeyOperation::Verify. HS384Key in jwt-simple is bidirectional; callers that need one-directional HMAC usage should remove key_ops before converting.

Source§

type Error = JwtSimpleKeyConversionError

The type returned in the event of a conversion error.
Source§

impl TryFrom<&Key> for HS512Key

Available on crate feature jwt-simple only.
Source§

fn try_from(jwk: &Key) -> Result<Self, JwtSimpleKeyConversionError>

§Errors

Returns JwtSimpleKeyConversionError::IncompatibleKey if key_ops is present but does not include both KeyOperation::Sign and KeyOperation::Verify. HS512Key in jwt-simple is bidirectional; callers that need one-directional HMAC usage should remove key_ops before converting.

Source§

type Error = JwtSimpleKeyConversionError

The type returned in the event of a conversion error.
Source§

impl TryFrom<&Key> for JsonWebKey

Available on crate feature web-crypto and WebAssembly only.

Conversion from Key to web_sys::JsonWebKey for WebCrypto usage.

§Supported Key Types

  • RSA: All RSA keys are supported
  • EC: P-256, P-384, P-521 curves are supported; secp256k1 is NOT supported
  • Symmetric: All symmetric keys are supported
  • OKP: NOT supported (Ed25519, Ed448, X25519, X448)

§Errors

Returns Error::UnsupportedForWebCrypto if the key type or curve is not supported by WebCrypto.

§Examples

use jwk_simple::Key;
use std::convert::TryInto;

let key: Key = serde_json::from_str(r#"{"kty":"RSA","n":"...","e":"AQAB"}"#)?;
let jwk: web_sys::JsonWebKey = (&key).try_into()?;
assert_eq!(jwk.get_kty(), "RSA");
Source§

type Error = Error

The type returned in the event of a conversion error.
Source§

fn try_from(key: &Key) -> Result<Self>

Performs the conversion.
Source§

impl TryFrom<&Key> for PS256KeyPair

Available on crate feature jwt-simple only.
Source§

type Error = JwtSimpleKeyConversionError

The type returned in the event of a conversion error.
Source§

fn try_from(jwk: &Key) -> Result<Self, JwtSimpleKeyConversionError>

Performs the conversion.
Source§

impl TryFrom<&Key> for PS256PublicKey

Available on crate feature jwt-simple only.
Source§

type Error = JwtSimpleKeyConversionError

The type returned in the event of a conversion error.
Source§

fn try_from(jwk: &Key) -> Result<Self, JwtSimpleKeyConversionError>

Performs the conversion.
Source§

impl TryFrom<&Key> for PS384KeyPair

Available on crate feature jwt-simple only.
Source§

type Error = JwtSimpleKeyConversionError

The type returned in the event of a conversion error.
Source§

fn try_from(jwk: &Key) -> Result<Self, JwtSimpleKeyConversionError>

Performs the conversion.
Source§

impl TryFrom<&Key> for PS384PublicKey

Available on crate feature jwt-simple only.
Source§

type Error = JwtSimpleKeyConversionError

The type returned in the event of a conversion error.
Source§

fn try_from(jwk: &Key) -> Result<Self, JwtSimpleKeyConversionError>

Performs the conversion.
Source§

impl TryFrom<&Key> for PS512KeyPair

Available on crate feature jwt-simple only.
Source§

type Error = JwtSimpleKeyConversionError

The type returned in the event of a conversion error.
Source§

fn try_from(jwk: &Key) -> Result<Self, JwtSimpleKeyConversionError>

Performs the conversion.
Source§

impl TryFrom<&Key> for PS512PublicKey

Available on crate feature jwt-simple only.
Source§

type Error = JwtSimpleKeyConversionError

The type returned in the event of a conversion error.
Source§

fn try_from(jwk: &Key) -> Result<Self, JwtSimpleKeyConversionError>

Performs the conversion.
Source§

impl TryFrom<&Key> for RS256KeyPair

Available on crate feature jwt-simple only.
Source§

type Error = JwtSimpleKeyConversionError

The type returned in the event of a conversion error.
Source§

fn try_from(jwk: &Key) -> Result<Self, JwtSimpleKeyConversionError>

Performs the conversion.
Source§

impl TryFrom<&Key> for RS256PublicKey

Available on crate feature jwt-simple only.
Source§

type Error = JwtSimpleKeyConversionError

The type returned in the event of a conversion error.
Source§

fn try_from(jwk: &Key) -> Result<Self, JwtSimpleKeyConversionError>

Performs the conversion.
Source§

impl TryFrom<&Key> for RS384KeyPair

Available on crate feature jwt-simple only.
Source§

type Error = JwtSimpleKeyConversionError

The type returned in the event of a conversion error.
Source§

fn try_from(jwk: &Key) -> Result<Self, JwtSimpleKeyConversionError>

Performs the conversion.
Source§

impl TryFrom<&Key> for RS384PublicKey

Available on crate feature jwt-simple only.
Source§

type Error = JwtSimpleKeyConversionError

The type returned in the event of a conversion error.
Source§

fn try_from(jwk: &Key) -> Result<Self, JwtSimpleKeyConversionError>

Performs the conversion.
Source§

impl TryFrom<&Key> for RS512KeyPair

Available on crate feature jwt-simple only.
Source§

type Error = JwtSimpleKeyConversionError

The type returned in the event of a conversion error.
Source§

fn try_from(jwk: &Key) -> Result<Self, JwtSimpleKeyConversionError>

Performs the conversion.
Source§

impl TryFrom<&Key> for RS512PublicKey

Available on crate feature jwt-simple only.
Source§

type Error = JwtSimpleKeyConversionError

The type returned in the event of a conversion error.
Source§

fn try_from(jwk: &Key) -> Result<Self, JwtSimpleKeyConversionError>

Performs the conversion.
Source§

impl TryFrom<Key> for ES256KeyPair

Available on crate feature jwt-simple only.
Source§

type Error = JwtSimpleKeyConversionError

The type returned in the event of a conversion error.
Source§

fn try_from(jwk: Key) -> Result<Self, JwtSimpleKeyConversionError>

Performs the conversion.
Source§

impl TryFrom<Key> for ES256PublicKey

Available on crate feature jwt-simple only.
Source§

type Error = JwtSimpleKeyConversionError

The type returned in the event of a conversion error.
Source§

fn try_from(jwk: Key) -> Result<Self, JwtSimpleKeyConversionError>

Performs the conversion.
Source§

impl TryFrom<Key> for ES256kKeyPair

Available on crate feature jwt-simple only.
Source§

type Error = JwtSimpleKeyConversionError

The type returned in the event of a conversion error.
Source§

fn try_from(jwk: Key) -> Result<Self, JwtSimpleKeyConversionError>

Performs the conversion.
Source§

impl TryFrom<Key> for ES256kPublicKey

Available on crate feature jwt-simple only.
Source§

type Error = JwtSimpleKeyConversionError

The type returned in the event of a conversion error.
Source§

fn try_from(jwk: Key) -> Result<Self, JwtSimpleKeyConversionError>

Performs the conversion.
Source§

impl TryFrom<Key> for ES384KeyPair

Available on crate feature jwt-simple only.
Source§

type Error = JwtSimpleKeyConversionError

The type returned in the event of a conversion error.
Source§

fn try_from(jwk: Key) -> Result<Self, JwtSimpleKeyConversionError>

Performs the conversion.
Source§

impl TryFrom<Key> for ES384PublicKey

Available on crate feature jwt-simple only.
Source§

type Error = JwtSimpleKeyConversionError

The type returned in the event of a conversion error.
Source§

fn try_from(jwk: Key) -> Result<Self, JwtSimpleKeyConversionError>

Performs the conversion.
Source§

impl TryFrom<Key> for Ed25519KeyPair

Available on crate feature jwt-simple only.
Source§

type Error = JwtSimpleKeyConversionError

The type returned in the event of a conversion error.
Source§

fn try_from(jwk: Key) -> Result<Self, JwtSimpleKeyConversionError>

Performs the conversion.
Source§

impl TryFrom<Key> for Ed25519PublicKey

Available on crate feature jwt-simple only.
Source§

type Error = JwtSimpleKeyConversionError

The type returned in the event of a conversion error.
Source§

fn try_from(jwk: Key) -> Result<Self, JwtSimpleKeyConversionError>

Performs the conversion.
Source§

impl TryFrom<Key> for HS256Key

Available on crate feature jwt-simple only.
Source§

type Error = JwtSimpleKeyConversionError

The type returned in the event of a conversion error.
Source§

fn try_from(jwk: Key) -> Result<Self, JwtSimpleKeyConversionError>

Performs the conversion.
Source§

impl TryFrom<Key> for HS384Key

Available on crate feature jwt-simple only.
Source§

type Error = JwtSimpleKeyConversionError

The type returned in the event of a conversion error.
Source§

fn try_from(jwk: Key) -> Result<Self, JwtSimpleKeyConversionError>

Performs the conversion.
Source§

impl TryFrom<Key> for HS512Key

Available on crate feature jwt-simple only.
Source§

type Error = JwtSimpleKeyConversionError

The type returned in the event of a conversion error.
Source§

fn try_from(jwk: Key) -> Result<Self, JwtSimpleKeyConversionError>

Performs the conversion.
Source§

impl TryFrom<Key> for PS256KeyPair

Available on crate feature jwt-simple only.
Source§

type Error = JwtSimpleKeyConversionError

The type returned in the event of a conversion error.
Source§

fn try_from(jwk: Key) -> Result<Self, JwtSimpleKeyConversionError>

Performs the conversion.
Source§

impl TryFrom<Key> for PS256PublicKey

Available on crate feature jwt-simple only.
Source§

type Error = JwtSimpleKeyConversionError

The type returned in the event of a conversion error.
Source§

fn try_from(jwk: Key) -> Result<Self, JwtSimpleKeyConversionError>

Performs the conversion.
Source§

impl TryFrom<Key> for PS384KeyPair

Available on crate feature jwt-simple only.
Source§

type Error = JwtSimpleKeyConversionError

The type returned in the event of a conversion error.
Source§

fn try_from(jwk: Key) -> Result<Self, JwtSimpleKeyConversionError>

Performs the conversion.
Source§

impl TryFrom<Key> for PS384PublicKey

Available on crate feature jwt-simple only.
Source§

type Error = JwtSimpleKeyConversionError

The type returned in the event of a conversion error.
Source§

fn try_from(jwk: Key) -> Result<Self, JwtSimpleKeyConversionError>

Performs the conversion.
Source§

impl TryFrom<Key> for PS512KeyPair

Available on crate feature jwt-simple only.
Source§

type Error = JwtSimpleKeyConversionError

The type returned in the event of a conversion error.
Source§

fn try_from(jwk: Key) -> Result<Self, JwtSimpleKeyConversionError>

Performs the conversion.
Source§

impl TryFrom<Key> for PS512PublicKey

Available on crate feature jwt-simple only.
Source§

type Error = JwtSimpleKeyConversionError

The type returned in the event of a conversion error.
Source§

fn try_from(jwk: Key) -> Result<Self, JwtSimpleKeyConversionError>

Performs the conversion.
Source§

impl TryFrom<Key> for RS256KeyPair

Available on crate feature jwt-simple only.
Source§

type Error = JwtSimpleKeyConversionError

The type returned in the event of a conversion error.
Source§

fn try_from(jwk: Key) -> Result<Self, JwtSimpleKeyConversionError>

Performs the conversion.
Source§

impl TryFrom<Key> for RS256PublicKey

Available on crate feature jwt-simple only.
Source§

type Error = JwtSimpleKeyConversionError

The type returned in the event of a conversion error.
Source§

fn try_from(jwk: Key) -> Result<Self, JwtSimpleKeyConversionError>

Performs the conversion.
Source§

impl TryFrom<Key> for RS384KeyPair

Available on crate feature jwt-simple only.
Source§

type Error = JwtSimpleKeyConversionError

The type returned in the event of a conversion error.
Source§

fn try_from(jwk: Key) -> Result<Self, JwtSimpleKeyConversionError>

Performs the conversion.
Source§

impl TryFrom<Key> for RS384PublicKey

Available on crate feature jwt-simple only.
Source§

type Error = JwtSimpleKeyConversionError

The type returned in the event of a conversion error.
Source§

fn try_from(jwk: Key) -> Result<Self, JwtSimpleKeyConversionError>

Performs the conversion.
Source§

impl TryFrom<Key> for RS512KeyPair

Available on crate feature jwt-simple only.
Source§

type Error = JwtSimpleKeyConversionError

The type returned in the event of a conversion error.
Source§

fn try_from(jwk: Key) -> Result<Self, JwtSimpleKeyConversionError>

Performs the conversion.
Source§

impl TryFrom<Key> for RS512PublicKey

Available on crate feature jwt-simple only.
Source§

type Error = JwtSimpleKeyConversionError

The type returned in the event of a conversion error.
Source§

fn try_from(jwk: Key) -> Result<Self, JwtSimpleKeyConversionError>

Performs the conversion.
Source§

impl Zeroize for Key

Source§

fn zeroize(&mut self)

Zero out this object from memory using Rust intrinsics which ensure the zeroization operation is not “optimized away” by the compiler.
Source§

impl Eq for Key

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> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<'a, T, E> AsTaggedExplicit<'a, E> for T
where T: 'a,

Source§

fn explicit(self, class: Class, tag: u32) -> TaggedParser<'a, Explicit, Self, E>

Source§

impl<'a, T, E> AsTaggedImplicit<'a, E> for T
where T: 'a,

Source§

fn implicit( self, class: Class, constructed: bool, tag: u32, ) -> TaggedParser<'a, Implicit, Self, E>

Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<Q, K> Equivalent<K> for Q
where Q: Eq + ?Sized, K: Borrow<Q> + ?Sized,

Source§

fn equivalent(&self, key: &K) -> bool

Compare self to key and return true if they are equal.
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T> Instrument for T

Source§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
Source§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> Pointable for T

Source§

const ALIGN: usize

The alignment of pointer.
Source§

type Init = T

The type for initializers.
Source§

unsafe fn init(init: <T as Pointable>::Init) -> usize

Initializes a with the given initializer. Read more
Source§

unsafe fn deref<'a>(ptr: usize) -> &'a T

Dereferences the given pointer. Read more
Source§

unsafe fn deref_mut<'a>(ptr: usize) -> &'a mut T

Mutably dereferences the given pointer. Read more
Source§

unsafe fn drop(ptr: usize)

Drops the object pointed to by the given pointer. Read more
Source§

impl<T> PolicyExt for T
where T: ?Sized,

Source§

fn and<P, B, E>(self, other: P) -> And<T, P>
where T: Policy<B, E>, P: Policy<B, E>,

Create a new Policy that returns Action::Follow only if self and other return Action::Follow. Read more
Source§

fn or<P, B, E>(self, other: P) -> Or<T, P>
where T: Policy<B, E>, P: Policy<B, E>,

Create a new Policy that returns Action::Follow if either self or other returns Action::Follow. Read more
Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

Source§

fn vzip(self) -> V

Source§

impl<T> WithSubscriber for T

Source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

impl<T> DeserializeOwned for T
where T: for<'de> Deserialize<'de>,