Skip to content

Commit

Permalink
init crates
Browse files Browse the repository at this point in the history
  • Loading branch information
kayhhh committed Oct 20, 2024
1 parent c01f2f5 commit 0a693a8
Show file tree
Hide file tree
Showing 16 changed files with 131 additions and 1 deletion.
2 changes: 1 addition & 1 deletion .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -23,13 +23,13 @@ jobs:
ref: ${{ github.event.pull_request.head.ref }}

- uses: DeterminateSystems/flake-checker-action@v9

- uses: DeterminateSystems/nix-installer-action@main
- uses: DeterminateSystems/magic-nix-cache-action@main
- uses: Swatinem/rust-cache@v2

- run: nix develop -c cargo clippy --fix --no-deps
- run: nix develop -c cargo fmt --all
- run: nix develop -c cargo ws exec --no-bail -- cargo rdme --force
- run: nix develop -c prettier -w .
- run: nix fmt
- uses: EndBug/add-and-commit@v9
Expand Down
23 changes: 23 additions & 0 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

7 changes: 7 additions & 0 deletions crates/xdid-core/Cargo.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
[package]
name = "xdid-core"
version.workspace = true
edition.workspace = true
repository.workspace = true
license.workspace = true
keywords.workspace = true
7 changes: 7 additions & 0 deletions crates/xdid-core/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
# xdid-core

<!-- cargo-rdme start -->

Core types for DID methods to implement.

<!-- cargo-rdme end -->
4 changes: 4 additions & 0 deletions crates/xdid-core/src/lib.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
//! Core types for DID methods to implement.

/// DID method.
pub trait Method {}
10 changes: 10 additions & 0 deletions crates/xdid-method-key/Cargo.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
[package]
name = "xdid-method-key"
version.workspace = true
edition.workspace = true
repository.workspace = true
license.workspace = true
keywords.workspace = true

[dependencies]
xdid-core = { path = "../xdid-core" }
7 changes: 7 additions & 0 deletions crates/xdid-method-key/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
# xdid-method-key

<!-- cargo-rdme start -->

Implementation of [did:key](https://w3c-ccg.github.io/did-method-key/), using [xdid](https://github.com/unavi-xyz/xdid).

<!-- cargo-rdme end -->
3 changes: 3 additions & 0 deletions crates/xdid-method-key/src/lib.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
//! Implementation of [did:key](https://w3c-ccg.github.io/did-method-key/), using [xdid](https://github.com/unavi-xyz/xdid).

pub fn hello() {}
10 changes: 10 additions & 0 deletions crates/xdid-method-web/Cargo.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
[package]
name = "xdid-method-web"
version.workspace = true
edition.workspace = true
repository.workspace = true
license.workspace = true
keywords.workspace = true

[dependencies]
xdid-core = { path = "../xdid-core" }
7 changes: 7 additions & 0 deletions crates/xdid-method-web/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
# xdid-method-web

<!-- cargo-rdme start -->

Implementation of [did:web](https://w3c-ccg.github.io/did-method-web/), using [xdid](https://github.com/unavi-xyz/xdid).

<!-- cargo-rdme end -->
1 change: 1 addition & 0 deletions crates/xdid-method-web/src/lib.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
//! Implementation of [did:web](https://w3c-ccg.github.io/did-method-web/), using [xdid](https://github.com/unavi-xyz/xdid).
10 changes: 10 additions & 0 deletions crates/xdid/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -5,3 +5,13 @@ edition.workspace = true
repository.workspace = true
license.workspace = true
keywords.workspace = true

[features]
default = ["did-key", "did-web"]
did-key = ["dep:xdid-method-key"]
did-web = ["dep:xdid-method-web"]

[dependencies]
xdid-core = { path = "../xdid-core" }
xdid-method-key = { path = "../xdid-method-key", optional = true }
xdid-method-web = { path = "../xdid-method-web", optional = true }
9 changes: 9 additions & 0 deletions crates/xdid/README.md
Original file line number Diff line number Diff line change
@@ -1 +1,10 @@
# xdid

<!-- cargo-rdme start -->

Simple [DID](https://www.w3.org/TR/did-core/) implementation, in Rust.

Add support for new methods using the [Method](xdid_core::Method) trait,
then create a [Resolver] to parse and resolve DIDs.

<!-- cargo-rdme end -->
18 changes: 18 additions & 0 deletions crates/xdid/src/lib.rs
Original file line number Diff line number Diff line change
@@ -1 +1,19 @@
//! Simple [DID](https://www.w3.org/TR/did-core/) implementation, in Rust.
//!
//! Add support for new methods using the [Method](xdid_core::Method) trait,
//! then create a [Resolver] to parse and resolve DIDs.

mod resolver;

pub use resolver::*;

pub mod core {
pub use xdid_core::*;
}

pub mod methods {
#[cfg(feature = "did-key")]
pub use xdid_method_key::*;
#[cfg(feature = "did-web")]
pub use xdid_method_web::*;
}
12 changes: 12 additions & 0 deletions crates/xdid/src/resolver.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
use xdid_core::Method;

/// DID resolver.
pub struct Resolver {
pub methods: Vec<Box<dyn Method>>,
}

impl Resolver {
pub async fn resolve(&self, _did: String) {
todo!();
}
}
2 changes: 2 additions & 0 deletions flake.nix
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,9 @@
checks = self.checks.${localSystem};
packages = with pkgs; [
cargo-machete
cargo-rdme
cargo-release
cargo-workspaces
nodePackages.prettier
rust-analyzer
];
Expand Down

0 comments on commit 0a693a8

Please sign in to comment.