Skip to content

Commit dbb556b

Browse files
committed
Add a Rust matcher for OpenID4VCI creation requests
1 parent 163ef92 commit dbb556b

File tree

13 files changed

+1094
-15
lines changed

13 files changed

+1094
-15
lines changed

matcher-rs/.gitignore

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
/target
2+
**/*.rs.bk
3+
/bin/
4+
pkg/
5+
wasm-pack.log

matcher-rs/Cargo.lock

Lines changed: 319 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

matcher-rs/Cargo.toml

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
[package]
2+
name = "matcher-rs"
3+
version = "0.1.0"
4+
authors = ["rensiyuan"]
5+
edition = "2024"
6+
build = "build.rs"
7+
8+
[lib]
9+
crate-type = ["cdylib", "rlib"]
10+
11+
[dependencies]
12+
lol_alloc = "0.4.1"
13+
serde = { version = "1.0", features = ["derive"] }
14+
serde_json = "1.0.145"
15+
16+
[dev-dependencies]
17+
18+
[build-dependencies]
19+
bindgen = "0.72.1"
20+
21+
[profile.release]
22+
# Tell `rustc` to optimize for small code size.
23+
opt-level = "s"
24+
lto = true

matcher-rs/build.rs

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
use std::env;
2+
use std::path::PathBuf;
3+
4+
fn main() {
5+
println!("cargo:rerun-if-changed=../matcher/credentialmanager.h");
6+
println!("cargo:rerun-if-env-changed=TARGET");
7+
8+
let builder = bindgen::Builder::default()
9+
.header("../matcher/credentialmanager.h")
10+
.clang_arg("-I/usr/include")
11+
.clang_arg("-fvisibility=default")
12+
.parse_callbacks(Box::new(bindgen::CargoCallbacks::new()));
13+
14+
let bindings = builder.generate().expect("Unable to generate bindings");
15+
16+
let out_path = PathBuf::from(env::var("OUT_DIR").unwrap());
17+
bindings
18+
.write_to_file(out_path.join("bindings.rs"))
19+
.expect("Couldn't write bindings!");
20+
}

matcher-rs/src/bin/issuance.rs

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
use matcher_rs::{credman::CredmanApiImpl, issuance::issuance_main};
2+
3+
fn main() {
4+
issuance_main(&mut CredmanApiImpl {}).unwrap();
5+
}
6+
7+
// Credman expects this as the entry point, but it isn't there if the target is wasm32-unknown-unknown.
8+
#[cfg(all(target_arch = "wasm32", target_os = "unknown"))]
9+
#[unsafe(no_mangle)]
10+
extern "C" fn _start() {
11+
main();
12+
}

matcher-rs/src/bindings.rs

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
#![allow(non_upper_case_globals)]
2+
#![allow(non_camel_case_types)]
3+
#![allow(non_snake_case)]
4+
#![allow(unused)]
5+
6+
include!(concat!(env!("OUT_DIR"), "/bindings.rs"));

0 commit comments

Comments
 (0)