co_didcomm/messages/headers/
prior_claims.rs1use std::{convert::TryFrom, str::FromStr};
2
3use crate::Error as CrateError;
4
5#[derive(Clone, Serialize, Deserialize, Debug, PartialEq, Eq)]
7pub struct PriorClaims {
8 sub: Option<String>,
9
10 iss: String,
11}
12
13impl FromStr for PriorClaims {
14 type Err = CrateError;
15
16 fn from_str(jwt: &str) -> Result<Self, Self::Err> {
17 Ok(serde_json::from_str(jwt)?)
18 }
19}
20
21impl TryFrom<&[u8]> for PriorClaims {
22 type Error = CrateError;
23
24 fn try_from(jwt: &[u8]) -> Result<Self, Self::Error> {
25 std::str::from_utf8(jwt)?.parse::<Self>()
26 }
27}