diff --git a/Cargo.toml b/Cargo.toml index 29d249f..40414e0 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -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" diff --git a/src/sd_jwt.rs b/src/sd_jwt.rs index a0682ec..3f93870 100644 --- a/src/sd_jwt.rs +++ b/src/sd_jwt.rs @@ -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 /// `~~~...~~`. -#[derive(Debug, Clone, Eq, PartialEq, Serialize, Deserialize)] +#[derive(Debug, Clone, Eq, PartialEq)] pub struct SdJwt { /// The JWT part. pub jwt: String, @@ -80,6 +79,13 @@ impl Display for SdJwt { } } +impl FromStr for SdJwt { + type Err = Error; + fn from_str(s: &str) -> std::result::Result { + Self::parse(s) + } +} + #[cfg(test)] mod test { use crate::SdJwt;