Skip to content

Commit

Permalink
Implement Display trait for DidDocument (print as json)
Browse files Browse the repository at this point in the history
Signed-off-by: Patrik Stas <[email protected]>
  • Loading branch information
Patrik-Stas committed Oct 21, 2023
1 parent 8a695d4 commit f7b039e
Showing 1 changed file with 8 additions and 0 deletions.
8 changes: 8 additions & 0 deletions did_doc/src/schema/did_doc.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
use std::collections::HashMap;
use std::fmt::Display;

use did_parser::{Did, DidUrl};
use serde::{Deserialize, Serialize};
Expand Down Expand Up @@ -42,6 +43,13 @@ pub struct DidDocument<E> {
extra: HashMap<String, Value>,
}

impl Display for DidDocument<()> {
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
let json = serde_json::to_string(self).unwrap();
write!(f, "{}", json)
}
}

impl<E> DidDocument<E> {
pub fn builder(id: Did) -> DidDocumentBuilder<E> {
DidDocumentBuilder::new(id)
Expand Down

0 comments on commit f7b039e

Please sign in to comment.