Struct jws::compact::DecodedMessage

source ·
pub struct DecodedMessage {
    pub header: JsonObject,
    pub payload: Vec<u8>,
}
Expand description

A compact JWS message with header and payload, but without signature.

The signature is left off because the signature can only be computed from (and verified for) a serialized message, whereas this struct represents a mostly decoded message (the payload is still raw bytes).

You can call decode_verify to decode and verify a message. Alternatively, you can call split_encoded_parts, decode the parts and then use a Verifier manually. The latter allows you to access the decoded message, even if it’s signature is invalid.

Fields§

§header: JsonObject§payload: Vec<u8>

Implementations§

source§

impl DecodedMessage

source

pub fn new(header: impl Into<JsonObject>, payload: impl Into<Vec<u8>>) -> Self

Create a new message from a header and a payload.

source

pub fn from_encoded_parts(header: &[u8], payload: &[u8]) -> Result<Self>

Create a new DecodedMessage by decoding the header and payload of a JWS Compact Serialization message.

source

pub fn parse_json<'de, T: Deserialize<'de> + 'de>(&'de self) -> Result<T, Error>

Parse the payload as JSON using serde.

The type must implement the serde::Deserialize trait

source

pub fn parse_json_value(&self) -> Result<JsonValue, Error>

Parse the payload as a JsonValue.

This method avoids the need for type annotations.

source

pub fn parse_json_object(&self) -> Result<JsonObject, Error>

Parse the payload as a JsonObject.

This method avoids the need for type annotations.

Trait Implementations§

source§

impl Clone for DecodedMessage

source§

fn clone(&self) -> DecodedMessage

Returns a copy 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 DecodedMessage

source§

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

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

impl PartialEq for DecodedMessage

source§

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

This method tests for self and other values to be equal, and is used by ==.
1.0.0 · source§

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

This method tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
source§

impl StructuralPartialEq for DecodedMessage

Auto Trait Implementations§

Blanket Implementations§

source§

impl<T> Any for Twhere T: 'static + ?Sized,

source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
source§

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

source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
source§

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

source§

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

Mutably borrows from an owned value. Read more
source§

impl<T> From<T> for T

source§

fn from(t: T) -> T

Returns the argument unchanged.

source§

impl<T, U> Into<U> for Twhere 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> Same for T

§

type Output = T

Should always be Self
source§

impl<T> ToOwned for Twhere T: Clone,

§

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 Twhere U: Into<T>,

§

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 Twhere U: TryFrom<T>,

§

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.