From 62e52ef44a25d55cbdb8a4d1c59daea18f4fce8d Mon Sep 17 00:00:00 2001 From: Daniel Mader Date: Tue, 14 May 2024 20:55:23 +0200 Subject: [PATCH] feat: add `Display` to `DidMethod` --- Cargo.lock | 39 ++++++++++++++++++++++++++++-------- Cargo.toml | 1 + producer/Cargo.toml | 1 + producer/src/did_document.rs | 10 ++++++++- 4 files changed, 42 insertions(+), 9 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 1fa4207..decfed6 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -2158,7 +2158,7 @@ dependencies = [ "multibase 0.9.1", "serde", "serde_json", - "strum", + "strum 0.25.0", "thiserror", "time", "url", @@ -2183,7 +2183,7 @@ dependencies = [ "serde", "serde_json", "serde_repr", - "strum", + "strum 0.25.0", "thiserror", "url", ] @@ -2198,7 +2198,7 @@ dependencies = [ "form_urlencoded", "identity_core", "serde", - "strum", + "strum 0.25.0", "thiserror", ] @@ -2214,7 +2214,7 @@ dependencies = [ "identity_verification", "indexmap 2.2.6", "serde", - "strum", + "strum 0.25.0", "thiserror", ] @@ -2254,7 +2254,7 @@ dependencies = [ "prefix-hex", "ref-cast", "serde", - "strum", + "strum 0.25.0", "thiserror", ] @@ -2287,7 +2287,7 @@ dependencies = [ "identity_document", "identity_iota_core", "serde", - "strum", + "strum 0.25.0", "thiserror", ] @@ -2339,7 +2339,7 @@ dependencies = [ "identity_jose", "serde", "serde_json", - "strum", + "strum 0.25.0", "thiserror", ] @@ -3747,6 +3747,7 @@ dependencies = [ "log", "serde", "shared", + "strum 0.26.2", "test-log", "tokio", "url", @@ -4786,7 +4787,16 @@ version = "0.25.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "290d54ea6f91c969195bdbcd7442c8c2a2ba87da8bf60a7ee86a235d4bc1e125" dependencies = [ - "strum_macros", + "strum_macros 0.25.3", +] + +[[package]] +name = "strum" +version = "0.26.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5d8cec3501a5194c432b2b7976db6b7d10ec95c253208b45f83f7136aa985e29" +dependencies = [ + "strum_macros 0.26.2", ] [[package]] @@ -4802,6 +4812,19 @@ dependencies = [ "syn 2.0.60", ] +[[package]] +name = "strum_macros" +version = "0.26.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c6cf59daf282c0a494ba14fd21610a0325f9f90ec9d1231dea26bcb1d696c946" +dependencies = [ + "heck", + "proc-macro2", + "quote", + "rustversion", + "syn 2.0.60", +] + [[package]] name = "subtle" version = "2.5.0" diff --git a/Cargo.toml b/Cargo.toml index 3ea22d1..7b01014 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -37,6 +37,7 @@ log = "0.4" rand = "0.8" serde_json = "1.0" signature = "2.2" +strum = { version = "0.26", features = ["derive"] } test-log = "0.2" thiserror = "1.0" tokio = { version = "1", features = ["full"] } diff --git a/producer/Cargo.toml b/producer/Cargo.toml index 74f777b..9d0d81a 100644 --- a/producer/Cargo.toml +++ b/producer/Cargo.toml @@ -20,6 +20,7 @@ iota-sdk.workspace = true iota_stronghold = { version = "2.0" } log = "0.4" serde = "1.0" +strum.workspace = true url = "2.5" [dev-dependencies] diff --git a/producer/src/did_document.rs b/producer/src/did_document.rs index ee48789..dcc2357 100644 --- a/producer/src/did_document.rs +++ b/producer/src/did_document.rs @@ -3,22 +3,30 @@ use identity_iota::iota::IotaDID; use serde::{Deserialize, Serialize}; use shared::error::ProducerError; use shared::JwkStorageWrapper; +use std::string::ToString; +use strum::Display; use crate::SecretManager; -#[derive(Serialize, Deserialize, Debug, Clone, PartialEq)] +#[derive(Serialize, Deserialize, Debug, Clone, PartialEq, Display)] pub enum DidMethod { #[serde(rename = "did:jwk")] + #[strum(serialize = "did:jwk")] Jwk, #[serde(rename = "did:key")] + #[strum(serialize = "did:key")] Key, #[serde(rename = "did:web")] + #[strum(serialize = "did:web")] Web, #[serde(rename = "did:iota:rms")] + #[strum(serialize = "did:iota:rms")] ShimmerTestnet, #[serde(rename = "did:iota:smr")] + #[strum(serialize = "did:iota:smr")] Shimmer, #[serde(rename = "did:iota")] + #[strum(serialize = "did:iota")] IotaMainnet, }