Enum biscuit::jws::Compact [] [src]

pub enum Compact<T, H> {
    Decoded {
        header: Header<H>,
        payload: T,
    },
    Encoded(Compact),
}

Compact representation of a JWS

This representation contains a payload (type T) (e.g. a claims set) and is (optionally) signed. This is the most common form of tokens used. The JWS can contain additional header fields provided by type H.

Serialization/deserialization is handled by serde. Before you transport the token, make sure you turn it into the encoded form first.

Examples

Signing and verifying a JWT with HS256

See an example in the biscuit::JWT type alias.

Variants

Decoded form of the JWS. This variant cannot be serialized or deserialized and will return an error.

Fields of Decoded

Embedded header

Payload, usually a claims set

Encoded and (optionally) signed JWT. Use this form to send to your clients

Methods

impl<T: CompactPart, H: Serialize + DeserializeOwned> Compact<T, H>
[src]

New decoded JWT

New encoded JWT

Consumes self and convert into encoded form. If the token is already encoded, this is a no-op.

Encode the JWT passed and sign the payload using the algorithm from the header and the secret The secret is dependent on the signing algorithm

Consumes self and convert into decoded form, verifying the signature, if any. If the token is already decoded, this is a no-op

Decode a token into the JWT struct and verify its signature If the token or its signature is invalid, it will return an error

Convenience method to get a reference to the encoded string from an encoded compact JWS

Convenience method to get a mutable reference to the encoded string from an encoded compact JWS

Convenience method to get a reference to the claims set from a decoded compact JWS

Convenience method to get a reference to the claims set from a decoded compact JWS

Convenience method to get a reference to the header from a decoded compact JWS

Convenience method to get a reference to the header from a decoded compact JWS

Consumes self, and move the payload and header out and return them as a tuple

Panics

Panics if the JWS is not decoded

Consumes self, and move the encoded Compact out and return it

Panics

Panics if the JWS is not encoded

Trait Implementations

impl<T: Clone, H: Clone> Clone for Compact<T, H>
[src]

Returns a copy of the value. Read more

Performs copy-assignment from source. Read more

impl<T: Debug, H: Debug> Debug for Compact<T, H>
[src]

Formats the value using the given formatter.

impl<T: Eq, H: Eq> Eq for Compact<T, H>
[src]

impl<T: PartialEq, H: PartialEq> PartialEq for Compact<T, H>
[src]

This method tests for self and other values to be equal, and is used by ==. Read more

This method tests for !=.

impl<T: CompactPart, H: Serialize + DeserializeOwned> CompactPart for Compact<T, H>
[src]

Implementation for embedded inside a JWE.

Convert this part into bytes

Convert a sequence of bytes into Self

Base64 decode into Self

Serialize Self to some form and then base64URL Encode