Struct jwt_compact::alg::StrongAlg[][src]

pub struct StrongAlg<T>(pub T);
Expand description

Wrapper around a JWT algorithm signalling that it supports only StrongKeys.

The wrapper will implement Algorithm if the wrapped value is an Algorithm with both signing and verifying keys convertible to StrongKeys.

Examples

let weak_key = Hs256Key::new(b"too short!");
assert!(StrongKey::try_from(weak_key).is_err());
// There is no way to create a `StrongKey` from `weak_key`!

let strong_key: StrongKey<_> = Hs256Key::generate(&mut thread_rng());
let claims = // ...
let token = StrongAlg(Hs256)
    .token(Header::default(), &claims, &strong_key)?;

Tuple Fields

0: T

Trait Implementations

Key used when issuing new tokens.

Key used when verifying tokens. May coincide with Self::SigningKey for symmetric algorithms (e.g., HS*). Read more

Signature produced by the algorithm.

Returns the name of this algorithm, as mentioned in the alg field of the JWT header.

Signs a message with the signing_key.

Verifies the message against the signature and verifying_key.

Returns a copy of the value. Read more

Performs copy-assignment from source. Read more

Formats the value using the given formatter. Read more

Returns the “default value” for a type. Read more

Auto Trait Implementations

Blanket Implementations

Gets the TypeId of self. Read more

Immutably borrows from an owned value. Read more

Mutably borrows from an owned value. Read more

Performs the conversion.

Performs the conversion.

Should always be Self

The resulting type after obtaining ownership.

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

🔬 This is a nightly-only experimental API. (toowned_clone_into)

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

The type returned in the event of a conversion error.

Performs the conversion.

The type returned in the event of a conversion error.

Performs the conversion.