diff --git a/did_parser/README.md b/did_parser/README.md new file mode 100644 index 0000000000..dad1b3a28f --- /dev/null +++ b/did_parser/README.md @@ -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 +``` + diff --git a/did_parser/examples/demo.rs b/did_parser/examples/demo.rs new file mode 100644 index 0000000000..729a40aa83 --- /dev/null +++ b/did_parser/examples/demo.rs @@ -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()); +}