pub enum Audience {
Single(String),
Multiple(Vec<String>),
}Expand description
The aud (audience) claim, per RFC 7519 §4.1.3: either a single
case-sensitive string, or a JSON array of such strings.
#[serde(untagged)] tries variants in declaration order on
deserialization, so a bare JSON string matches Audience::Single
first, and only a JSON array falls through to Audience::Multiple.
Serialization is not affected by declaration order — each variant
serializes as its own shape — so a token minted with a single audience
still serializes as a bare string, not a one-element array, matching
every token this crate has ever issued.
Variants§
Implementations§
Trait Implementations§
Source§impl<'de> Deserialize<'de> for Audience
impl<'de> Deserialize<'de> for Audience
Source§fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
Source§impl Display for Audience
Renders the audience for logging and display: a single audience as the
bare string, multiple as comma-separated values.
impl Display for Audience
Renders the audience for logging and display: a single audience as the bare string, multiple as comma-separated values.
This exists so that code reading an aud claim has an ergonomic path
back to a string. Without it, every format!("{}", claims.aud) and
tracing::info!(aud = %claims.aud) at a call site that previously held
a String is a hard compile error with no one-line replacement. Use
Audience::contains for membership tests — do not parse this
output back apart, since an audience value may itself contain a comma.
impl Eq for Audience
Source§impl PartialEq<str> for Audience
Compares against a single audience string, so claims.aud == "client"
keeps compiling where aud used to be a String. Note this is exact
equality against a single-valued audience, not membership — a
Audience::Multiple never equals a bare str, even one it contains.
Use Audience::contains when you mean “is this one of the audiences”.
impl PartialEq<str> for Audience
Compares against a single audience string, so claims.aud == "client"
keeps compiling where aud used to be a String. Note this is exact
equality against a single-valued audience, not membership — a
Audience::Multiple never equals a bare str, even one it contains.
Use Audience::contains when you mean “is this one of the audiences”.
impl StructuralPartialEq for Audience
Auto Trait Implementations§
impl Freeze for Audience
impl RefUnwindSafe for Audience
impl Send for Audience
impl Sync for Audience
impl Unpin for Audience
impl UnsafeUnpin for Audience
impl UnwindSafe for Audience
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> DeserializeOwned for Twhere
T: for<'de> Deserialize<'de>,
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
key and return true if they are equal.