Type Definition jws::header::HeadersRef
source · pub type HeadersRef<'a> = AvailableHeaders<&'a JsonObject>;
Expand description
References to the headers of a message.
Implementations
sourceimpl<'a> HeadersRef<'a>
impl<'a> HeadersRef<'a>
sourcepub fn protected(&self) -> Option<&'a JsonObject>
pub fn protected(&self) -> Option<&'a JsonObject>
Get the protected header, if it is available.
sourcepub fn unprotected(&self) -> Option<&'a JsonObject>
pub fn unprotected(&self) -> Option<&'a JsonObject>
Get the unprotected header, if it is available.
sourcepub fn get(&self, key: &str) -> Option<&'a JsonValue>
pub fn get(&self, key: &str) -> Option<&'a JsonValue>
Get a parameter from either the protected or unprotected header, depending on which are available and which has the parameter.
If a parameter is found in the protected header, the unprotected header is not consulted anymore.
sourcepub fn get_required(&self, key: &str) -> Result<&'a JsonValue>
pub fn get_required(&self, key: &str) -> Result<&'a JsonValue>
Get a required parameter from either header.
This is almost identical to get
, except that this function returns a properly formatter error instead of an empty optional.
sourcepub fn deserialize_required<T: Deserialize<'a> + 'a>(
&self,
key: &str
) -> Result<T>
pub fn deserialize_required<T: Deserialize<'a> + 'a>(
&self,
key: &str
) -> Result<T>
Get and deserialize a required parameter from either header.
This function delegates to get_required
and deserializes the result into the desired type.
Deserialization errors are reported as Error::InvalidHeaderParam
.