From 1ee05f244620bd67efc811fbddb981de49a62212 Mon Sep 17 00:00:00 2001 From: Ondrej Prazak Date: Mon, 6 Nov 2023 16:41:53 +0100 Subject: [PATCH] fix(did_parser): Add readme and simple example (#1047) Signed-off-by: Ondrej Prazak --- did_parser/README.md | 23 +++++++++++++++++++++++ did_parser/examples/demo.rs | 11 +++++++++++ 2 files changed, 34 insertions(+) create mode 100644 did_parser/README.md create mode 100644 did_parser/examples/demo.rs 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..21f20ef500 --- /dev/null +++ b/did_parser/examples/demo.rs @@ -0,0 +1,11 @@ +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); + + // parse a string into DID URL + let did_url = DidUrl::parse("did:example:123456789abcdefghi;param=value?query=value".into()).unwrap(); + println!("{:?}", did_url); +}