pub struct StatusType(pub u8);sd-jwt only.Expand description
A status type value (Token Status List §7): a number in 0..=255, with the registered
meanings as constants.
It serializes as its registered name when it has one of its own ("VALID", "INVALID",
"SUSPENDED") and as a number otherwise. APPLICATION_SPECIFIC names 0x03 and
0x0C-0x0F alike, so those serialize as numbers too. It deserializes from a registered
name, a number in 0..=255, or that number as a decimal string; parse and
FromStr accept the same strings. Names are case-sensitive. Since the form depends on the
value, deserializing needs a self-describing format such as JSON or CBOR.
§Examples
use identity_kit::sd_jwt_vc::StatusType;
use serde_json::json;
assert_eq!(serde_json::to_value(StatusType::SUSPENDED)?, json!("SUSPENDED"));
assert_eq!(serde_json::to_value(StatusType(3))?, json!(3));
assert_eq!(serde_json::from_value::<StatusType>(json!("INVALID"))?, StatusType::INVALID);
assert_eq!(serde_json::from_value::<StatusType>(json!(12))?, StatusType(0x0C));
assert_eq!("VALID".parse::<StatusType>()?, StatusType::VALID);
assert!("APPLICATION_SPECIFIC".parse::<StatusType>().is_err());Tuple Fields§
§0: u8Implementations§
Source§impl StatusType
impl StatusType
Sourcepub const fn name(self) -> Option<&'static str>
pub const fn name(self) -> Option<&'static str>
The registered name of the value, if it has one.
Sourcepub fn parse(s: &str) -> Result<Self, StatusListError>
pub fn parse(s: &str) -> Result<Self, StatusListError>
The value named s: VALID, INVALID, SUSPENDED, or a decimal number in
0..=255.
§Errors
StatusListError::UnknownStatusType for anything else, APPLICATION_SPECIFIC
included: it names several values.
Trait Implementations§
Source§impl Clone for StatusType
impl Clone for StatusType
impl Copy for StatusType
Source§impl Debug for StatusType
impl Debug for StatusType
Source§impl<'de> Deserialize<'de> for StatusType
impl<'de> Deserialize<'de> for StatusType
Source§fn deserialize<D: Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error>
fn deserialize<D: Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error>
Source§impl Display for StatusType
impl Display for StatusType
impl Eq for StatusType
Source§impl From<u8> for StatusType
impl From<u8> for StatusType
Source§impl FromStr for StatusType
impl FromStr for StatusType
Source§impl Hash for StatusType
impl Hash for StatusType
Source§impl Ord for StatusType
impl Ord for StatusType
1.21.0 (const: unstable) · Source§fn max(self, other: Self) -> Selfwhere
Self: Sized,
fn max(self, other: Self) -> Selfwhere
Self: Sized,
1.21.0 (const: unstable) · Source§fn min(self, other: Self) -> Selfwhere
Self: Sized,
fn min(self, other: Self) -> Selfwhere
Self: Sized,
Source§impl PartialEq for StatusType
impl PartialEq for StatusType
Source§impl PartialOrd for StatusType
impl PartialOrd for StatusType
Source§impl PartialSchema for StatusType
Available on crate feature utoipa only.
impl PartialSchema for StatusType
utoipa only.Source§impl Serialize for StatusType
impl Serialize for StatusType
impl StructuralPartialEq for StatusType
Auto Trait Implementations§
impl Freeze for StatusType
impl RefUnwindSafe for StatusType
impl Send for StatusType
impl Sync for StatusType
impl Unpin for StatusType
impl UnsafeUnpin for StatusType
impl UnwindSafe for StatusType
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
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<Q, K> Comparable<K> for Q
impl<Q, K> Comparable<K> for Q
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.