identity_credential/credential/jpt.rs
1// Copyright 2020-2024 IOTA Stiftung, Fondazione Links
2// SPDX-License-Identifier: Apache-2.0
3
4use serde::Deserialize;
5use serde::Serialize;
6
7/// This JSON Proof Token could represent a JWP both in the Issued and Presented forms.
8#[derive(Debug, Clone, Serialize, Deserialize, Eq, PartialEq)]
9pub struct Jpt(String);
10
11impl Jpt {
12 /// Creates a new `Jwt` from the given string.
13 pub fn new(jpt_string: String) -> Self {
14 Self(jpt_string)
15 }
16
17 /// Returns a reference of the JWT string.
18 pub fn as_str(&self) -> &str {
19 &self.0
20 }
21}
22
23impl From<String> for Jpt {
24 fn from(jpt: String) -> Self {
25 Self::new(jpt)
26 }
27}
28
29impl From<Jpt> for String {
30 fn from(jpt: Jpt) -> Self {
31 jpt.0
32 }
33}