Skip to content

Commit

Permalink
Merge pull request #11 from iotaledger/fix/serialize-deserialize-as-e…
Browse files Browse the repository at this point in the history
…ncoder-decoder

Remove Serialize and Deserialize implementation for SdJwt
  • Loading branch information
UMR1352 authored Mar 12, 2024
2 parents 43a239f + 96bd015 commit b04472f
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 3 deletions.
1 change: 1 addition & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ itertools = { version = "0.12", default-features = false, features = ["use_std"]
iota-crypto = { version = "0.23", default-features = false, features = ["sha"], optional = true }
serde = { version = "1.0", default-features = false, features = ["derive"] }
json-pointer = "0.3.4"
serde_with = "3.6.1"

[dev-dependencies]
josekit = "0.8.4"
Expand Down
12 changes: 9 additions & 3 deletions src/sd_jwt.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,16 +2,15 @@
// SPDX-License-Identifier: Apache-2.0

use std::fmt::Display;
use std::str::FromStr;

use crate::Error;
use crate::Result;
use itertools::Itertools;
use serde::Deserialize;
use serde::Serialize;

/// Representation of an SD-JWT of the format
/// `<Issuer-signed JWT>~<Disclosure 1>~<Disclosure 2>~...~<Disclosure N>~<optional KB-JWT>`.
#[derive(Debug, Clone, Eq, PartialEq, Serialize, Deserialize)]
#[derive(Debug, Clone, Eq, PartialEq)]
pub struct SdJwt {
/// The JWT part.
pub jwt: String,
Expand Down Expand Up @@ -80,6 +79,13 @@ impl Display for SdJwt {
}
}

impl FromStr for SdJwt {
type Err = Error;
fn from_str(s: &str) -> std::result::Result<Self, Self::Err> {
Self::parse(s)
}
}

#[cfg(test)]
mod test {
use crate::SdJwt;
Expand Down

0 comments on commit b04472f

Please sign in to comment.