-
Notifications
You must be signed in to change notification settings - Fork 83
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Browse files
Browse the repository at this point in the history
Signed-off-by: Ondrej Prazak <[email protected]>
- Loading branch information
Showing
2 changed files
with
42 additions
and
0 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
# did_parser | ||
|
||
## Overview | ||
Rust crate for parsing [DIDs](https://www.w3.org/TR/did-core/#did-syntax) and [DID URLs](https://www.w3.org/TR/did-core/#did-url-syntax). | ||
|
||
## Features | ||
- **DID Parsing**: Capability to parse `did:` strings, ensuring they comply with the DID specifications. | ||
- **DID URL**: Functionality to parse DID URLs. | ||
|
||
## Getting Started | ||
### Installation | ||
Add the did_parser library as a dependency in your `Cargo.toml` file: | ||
```toml | ||
[dependencies] | ||
did_parser = { tag = "0.61.0", git = "https://github.com/hyperledger/aries-vcx" } | ||
``` | ||
|
||
## Demo | ||
To get you off the ground, have a look at the [demo](./examples/demo.rs). It demonstrates a basic functionality. You can run the demo with the following command: | ||
```bash | ||
cargo run --example demo | ||
``` | ||
|
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 |
---|---|---|
@@ -0,0 +1,19 @@ | ||
use did_parser::{Did, DidUrl}; | ||
|
||
fn main() { | ||
// parse a string into DID | ||
let did = Did::parse("did:web:w3c-ccg.github.io".into()).unwrap(); | ||
println!("{:?}", did.did()); | ||
println!("{:?}", did.method()); | ||
println!("{:?}", did.id()); | ||
|
||
// parse a string into DID URL | ||
let did_url = | ||
DidUrl::parse("did:example:123456789abcdefghi/foo;param=value?query=value".into()).unwrap(); | ||
println!("{:?}", did_url.did()); | ||
println!("{:?}", did_url.did_url()); | ||
println!("{:?}", did_url.method()); | ||
println!("{:?}", did_url.id()); | ||
println!("{:?}", did_url.path()); | ||
println!("{:?}", did_url.queries()); | ||
} |