generated from TBD54566975/tbd-project-template
-
Notifications
You must be signed in to change notification settings - Fork 17
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add PortableDid from_json_string() and to_json_string()
- Loading branch information
1 parent
8c0bf68
commit 1147ab8
Showing
9 changed files
with
104 additions
and
61 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,16 +1,23 @@ | ||
use web5::dids::portable_did::PortableDid as InnerPortableDid; | ||
|
||
use crate::errors::Result; | ||
use web5::{ | ||
dids::portable_did::PortableDid as InnerPortableDid, | ||
json::{FromJson, ToJson}, | ||
}; | ||
|
||
pub struct PortableDid(pub InnerPortableDid); | ||
|
||
impl PortableDid { | ||
pub fn new(json: &str) -> Result<Self> { | ||
let inner_portable_did = InnerPortableDid::new(json)?; | ||
pub fn from_json_string(json: &str) -> Result<Self> { | ||
let inner_portable_did = InnerPortableDid::from_json_string(json)?; | ||
Ok(Self(inner_portable_did)) | ||
} | ||
|
||
pub fn get_data(&self) -> InnerPortableDid { | ||
self.0.clone() | ||
} | ||
|
||
pub fn to_json_string(&self) -> Result<String> { | ||
let json_string = self.0.to_json_string()?; | ||
Ok(json_string) | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters