did-common
A rust library for parsing Decentralized Identifiers (DIDs) following the DID specification by the W3C.
Usage: DID
Add this to your Cargo.toml
:
[]
= "^0.1"
and this to your crate root (if you're using Rust 2015):
extern crate did_common;
Here is how to to parse or validate a simple DID string:
use Did;
let did = parse.unwrap;
if is_valid
// output: DID is valid.
You can also build a DID using a builder:
use DidBuilder;
let did =
new
.with_params
.with_fragment
.build;
println!;
// output: did:example:1234;service=agent#keys-1
Usage: DID Document
Here is how to parse a simple DID Document:
use DidDocument;
use json_parse;
let did_doc = parse;
println!;
// output: did:example:21tDAKCERh95uGgKbJNHYp
You can also build a DID Document using a builder:
use DidDocumentBuilder;
let did_doc =
new
.with_pubkeys
.build;
let key = did_doc.pub_keys.first.unwrap;
println!;
// output: did:example:123456789abcdefghi#keys-1
License
This project is licensed under either of
- Apache License, Version 2.0, (LICENSE-APACHE or http://www.apache.org/licenses/LICENSE-2.0)
- MIT license (LICENSE-MIT or http://opensource.org/licenses/MIT)
at your option.