Enum jws::header::AvailableHeaders
source · pub enum AvailableHeaders<T> {
Both {
protected: T,
unprotected: T,
},
ProtectedOnly(T),
UnprotectedOnly(T),
}
Expand description
The available message headers.
The message might have a protected header and/or an unprotected header. However, it must always have atleast one of the two.
Variants
Implementations
sourceimpl<'a> AvailableHeaders<&'a BTreeMap<String, Value, Global>>
impl<'a> AvailableHeaders<&'a BTreeMap<String, Value, Global>>
sourcepub fn unprotected(&self) -> Option<&'a HeaderMap>
pub fn unprotected(&self) -> Option<&'a HeaderMap>
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
errors.
sourceimpl<'a> AvailableHeaders<&'a mut BTreeMap<String, Value, Global>>
impl<'a> AvailableHeaders<&'a mut BTreeMap<String, Value, Global>>
sourcepub fn insert<T>(&mut self, key: String, value: T) -> Option<JsonValue>where
JsonValue: From<T>,
pub fn insert<T>(&mut self, key: String, value: T) -> Option<JsonValue>where
JsonValue: From<T>,
Insert a value into either of the available headers.
If the protected header is available, the value is inserted into that one. Otherwise, it is inserted into the unprotected header.
If the value is inserted into the protected header but the key exists in the unprotected header, it is removed from the unprotected header.
Trait Implementations
sourceimpl<T: Clone> Clone for AvailableHeaders<T>
impl<T: Clone> Clone for AvailableHeaders<T>
sourcefn clone(&self) -> AvailableHeaders<T>
fn clone(&self) -> AvailableHeaders<T>
1.0.0 · sourcefn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source
. Read more