Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(did_parser): Add readme and simple example (#1047) #1051

Merged
merged 1 commit into from
Nov 8, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
23 changes: 23 additions & 0 deletions did_parser/README.md
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
```

19 changes: 19 additions & 0 deletions did_parser/examples/demo.rs
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());
}
Loading