diff --git a/Cargo.lock b/Cargo.lock index bfa669f..2e74df7 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -803,6 +803,7 @@ checksum = "d530e1a18b1cb4c484e6e34556a0d948706958449fca0cab753d649f2bce3d1f" dependencies = [ "equivalent", "hashbrown", + "serde", ] [[package]] @@ -1164,6 +1165,8 @@ dependencies = [ "termcolor", "tokio", "toml", + "utoipa", + "utoipa-rapidoc", "warp", ] @@ -1486,6 +1489,19 @@ dependencies = [ "serde", ] +[[package]] +name = "serde_yaml" +version = "0.9.27" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3cc7a1570e38322cfe4154732e5110f887ea57e22b76f4bfd32b5bdd3368666c" +dependencies = [ + "indexmap", + "itoa", + "ryu", + "serde", + "unsafe-libyaml", +] + [[package]] name = "sha1" version = "0.10.6" @@ -1867,6 +1883,12 @@ version = "0.1.11" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "e51733f11c9c4f72aa0c160008246859e340b00807569a0da0e7a1079b27ba85" +[[package]] +name = "unsafe-libyaml" +version = "0.2.9" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f28467d3e1d3c6586d8f25fa243f544f5800fec42d97032474e17222c2b75cfa" + [[package]] name = "url" version = "2.5.0" @@ -1890,6 +1912,42 @@ version = "0.2.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "711b9620af191e0cdc7468a8d14e709c3dcdb115b36f838e601583af800a370a" +[[package]] +name = "utoipa" +version = "4.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0ff05e3bac2c9428f57ade702667753ca3f5cf085e2011fe697de5bfd49aa72d" +dependencies = [ + "indexmap", + "serde", + "serde_json", + "serde_yaml", + "utoipa-gen", +] + +[[package]] +name = "utoipa-gen" +version = "4.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5f0b6f4667edd64be0e820d6631a60433a269710b6ee89ac39525b872b76d61d" +dependencies = [ + "proc-macro-error", + "proc-macro2", + "quote", + "syn 2.0.39", +] + +[[package]] +name = "utoipa-rapidoc" +version = "1.0.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d54a9a294323cfd98cb7e210ffa3d65ec83f3c09b17b5c49ce17d9658101e162" +dependencies = [ + "serde", + "serde_json", + "utoipa", +] + [[package]] name = "version_check" version = "0.9.4" diff --git a/Cargo.toml b/Cargo.toml index 2b8c0c1..22a11c6 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -28,6 +28,7 @@ lazy_static = "1.4.0" prometheus = "0.13.3" serde_json = "1.0.108" simple-logging = "2.0.2" +utoipa-rapidoc = "1.0.0" pretty_env_logger = "0.5.0" clap-verbosity-flag = "2.1.0" global_placeholders = "0.1.0" @@ -36,6 +37,7 @@ psutil = { version = "3.2.2", features = ["serde"] } tabled = { version = "0.14.0", features = ["color"] } chrono = { version = "0.4.23", features = ["serde"] } serde = { version = "1.0.192", features = ["derive"] } +utoipa = { version = "4.1.0", features = ["serde_yaml"] } [build-dependencies] chrono = "0.4.23" diff --git a/Maidfile.toml b/Maidfile.toml index 49917f0..9a9ffeb 100644 --- a/Maidfile.toml +++ b/Maidfile.toml @@ -23,5 +23,5 @@ script = [ "killall pmc", "maid build -q", "sudo cp bin/pmc /usr/local/bin", - "echo Copied binary!" + "echo Copied binary!" ] diff --git a/build.rs b/build.rs index 310a393..c63a52e 100644 --- a/build.rs +++ b/build.rs @@ -28,12 +28,20 @@ fn main() { /* cc linking */ cxx_build::bridge("src/lib.rs") - .file("src/cc/bridge.cc") - .file("src/cc/process.cc") - .file("src/cc/fork.cc") + .file("lib/bridge.cc") + .file("lib/process.cc") + .file("lib/fork.cc") .flag_if_supported("-std=c++17") .compile("bridge"); - let watched = vec!["lib.rs", "cc/bridge.cc", "cc/process.cc", "cc/fork.cc", "include/bridge.h", "include/process.h", "include/fork.h"]; - watched.iter().for_each(|file| println!("cargo:rerun-if-changed=src/{}", file)); + let watched = vec![ + "src/lib.rs", + "lib/bridge.cc", + "lib/process.cc", + "lib/fork.cc", + "lib/include/bridge.h", + "lib/include/process.h", + "lib/include/fork.h", + ]; + watched.iter().for_each(|file| println!("cargo:rerun-if-changed={file}")); } diff --git a/src/cc/bridge.cc b/lib/bridge.cc similarity index 97% rename from src/cc/bridge.cc rename to lib/bridge.cc index cd9914e..fe7c9e2 100644 --- a/src/cc/bridge.cc +++ b/lib/bridge.cc @@ -1,5 +1,5 @@ -#include "../include/bridge.h" -#include "../include/process.h" +#include "include/bridge.h" +#include "include/process.h" #include #include diff --git a/src/cc/fork.cc b/lib/fork.cc similarity index 98% rename from src/cc/fork.cc rename to lib/fork.cc index 322ad5e..75abd5d 100644 --- a/src/cc/fork.cc +++ b/lib/fork.cc @@ -1,4 +1,4 @@ -#include "../include/fork.h" +#include "include/fork.h" #include #include #include diff --git a/src/include/bridge.h b/lib/include/bridge.h similarity index 100% rename from src/include/bridge.h rename to lib/include/bridge.h diff --git a/src/include/fork.h b/lib/include/fork.h similarity index 100% rename from src/include/fork.h rename to lib/include/fork.h diff --git a/src/include/process.h b/lib/include/process.h similarity index 100% rename from src/include/process.h rename to lib/include/process.h diff --git a/src/include/rust.h b/lib/include/rust.h similarity index 100% rename from src/include/rust.h rename to lib/include/rust.h diff --git a/src/cc/process.cc b/lib/process.cc similarity index 98% rename from src/cc/process.cc rename to lib/process.cc index abf7f6a..06f0e62 100644 --- a/src/cc/process.cc +++ b/lib/process.cc @@ -1,4 +1,4 @@ -#include "../include/process.h" +#include "include/process.h" #include #include #include diff --git a/src/lib.rs b/src/lib.rs index e86684d..7884423 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -30,9 +30,9 @@ pub mod service { } unsafe extern "C++" { - include!("pmc/src/include/process.h"); - include!("pmc/src/include/bridge.h"); - include!("pmc/src/include/fork.h"); + include!("pmc/lib/include/process.h"); + include!("pmc/lib/include/bridge.h"); + include!("pmc/lib/include/fork.h"); type Callback = crate::Callback; pub fn stop(pid: i64) -> i64;