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
impl DecodedMessage
sourcepub fn new(header: impl Into<JsonObject>, payload: impl Into<Vec<u8>>) -> Self
pub fn new(header: impl Into<JsonObject>, payload: impl Into<Vec<u8>>) -> Self
Create a new message from a header and a payload.
sourcepub fn from_encoded_parts(header: &[u8], payload: &[u8]) -> Result<Self>
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.
sourcepub fn parse_json<'de, T: Deserialize<'de> + 'de>(&'de self) -> Result<T, Error>
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
sourcepub fn parse_json_value(&self) -> Result<JsonValue, Error>
pub fn parse_json_value(&self) -> Result<JsonValue, Error>
Parse the payload as a JsonValue
.
This method avoids the need for type annotations.
sourcepub fn parse_json_object(&self) -> Result<JsonObject, Error>
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
impl Clone for DecodedMessage
source§fn clone(&self) -> DecodedMessage
fn clone(&self) -> DecodedMessage
1.0.0 · source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source
. Read moresource§impl Debug for DecodedMessage
impl Debug for DecodedMessage
source§impl PartialEq for DecodedMessage
impl PartialEq for DecodedMessage
source§fn eq(&self, other: &DecodedMessage) -> bool
fn eq(&self, other: &DecodedMessage) -> bool
self
and other
values to be equal, and is used
by ==
.