document hot_lib for developers a bit
Signed-off-by: strawberry <strawberry@puppygock.gay>
This commit is contained in:
parent
ed86a4aa9e
commit
9c0c4c292c
5 changed files with 28 additions and 13 deletions
10
Cargo.lock
generated
10
Cargo.lock
generated
|
@ -567,6 +567,7 @@ dependencies = [
|
|||
"hickory-resolver",
|
||||
"hmac",
|
||||
"hot-lib-reloader",
|
||||
"hot_lib",
|
||||
"http 1.1.0",
|
||||
"http-body-util",
|
||||
"hyper 1.3.1",
|
||||
|
@ -575,7 +576,6 @@ dependencies = [
|
|||
"ipaddress",
|
||||
"itertools 0.12.1",
|
||||
"jsonwebtoken",
|
||||
"lib",
|
||||
"log",
|
||||
"loole",
|
||||
"lru-cache",
|
||||
|
@ -1347,6 +1347,10 @@ dependencies = [
|
|||
"syn 1.0.109",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "hot_lib"
|
||||
version = "0.1.0"
|
||||
|
||||
[[package]]
|
||||
name = "html5ever"
|
||||
version = "0.26.0"
|
||||
|
@ -1797,10 +1801,6 @@ version = "1.3.0"
|
|||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "830d08ce1d1d941e6b30645f1a0eb5643013d835ce3779a5fc208261dbe10f55"
|
||||
|
||||
[[package]]
|
||||
name = "lib"
|
||||
version = "0.1.0"
|
||||
|
||||
[[package]]
|
||||
name = "libc"
|
||||
version = "0.2.153"
|
||||
|
|
|
@ -18,14 +18,16 @@ rust-version = "1.76.0"
|
|||
|
||||
# for hot lib reload
|
||||
[workspace]
|
||||
members = ["lib"]
|
||||
members = ["hot_lib"]
|
||||
|
||||
[dependencies]
|
||||
console-subscriber = { version = "0.1", optional = true }
|
||||
|
||||
# for hot lib reload
|
||||
# see https://github.com/rksm/hot-lib-reloader-rs?tab=readme-ov-file#usage for more details if you are a dev
|
||||
hot-lib-reloader = { version = "^0.7", optional = true }
|
||||
lib = { path = "lib", optional = true }
|
||||
hot_lib = { path = "hot_lib", optional = true }
|
||||
# not sure if we need this, will anyone be using hot lib reload on release profile?
|
||||
#no-mangle-if-debug = { version = "*" }
|
||||
|
||||
# Used for secure identifiers
|
||||
|
@ -406,7 +408,7 @@ perf_measurements = [
|
|||
# incompatible with release_max_log_level
|
||||
tokio_console = ["console-subscriber", "tokio/tracing"]
|
||||
|
||||
hot_reload = ["dep:hot-lib-reloader", "lib"]
|
||||
hot_reload = ["dep:hot-lib-reloader", "hot_lib"]
|
||||
|
||||
hardened_malloc = ["hardened_malloc-rs"]
|
||||
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
[package]
|
||||
name = "lib"
|
||||
name = "hot_lib"
|
||||
version = "0.1.0"
|
||||
edition = "2021"
|
||||
|
|
@ -1,3 +1,6 @@
|
|||
//! hot reloadable functions, generally called by the admin room test commands
|
||||
//! see https://github.com/rksm/hot-lib-reloader-rs?tab=readme-ov-file#usage for more details if you are a dev
|
||||
|
||||
#[no_mangle]
|
||||
pub fn test_command() {
|
||||
println!("aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa");
|
|
@ -1,21 +1,30 @@
|
|||
use clap::Subcommand;
|
||||
//! test commands generally used for hot lib reloadable functions.
|
||||
//! see https://github.com/rksm/hot-lib-reloader-rs?tab=readme-ov-file#usage for more details if you are a dev
|
||||
|
||||
//#[cfg(not(feature = "hot_reload"))]
|
||||
//#[allow(unused_imports)]
|
||||
//#[allow(clippy::wildcard_imports)]
|
||||
// non hot reloadable functions (?)
|
||||
//use hot_lib::*;
|
||||
#[cfg(feature = "hot_reload")]
|
||||
#[allow(unused_imports)]
|
||||
#[allow(clippy::wildcard_imports)]
|
||||
use hot_lib::*;
|
||||
use hot_lib_funcs::*;
|
||||
use ruma::events::room::message::RoomMessageEventContent;
|
||||
|
||||
use crate::{debug_error, Result};
|
||||
|
||||
#[cfg(feature = "hot_reload")]
|
||||
#[hot_lib_reloader::hot_module(dylib = "lib")]
|
||||
mod hot_lib {
|
||||
mod hot_lib_funcs {
|
||||
// these will be functions from lib.rs, so `use hot_lib_funcs::test_command;`
|
||||
hot_functions_from_file!("lib/src/lib.rs");
|
||||
}
|
||||
|
||||
#[cfg_attr(test, derive(Debug))]
|
||||
#[derive(Subcommand)]
|
||||
#[derive(clap::Subcommand)]
|
||||
pub(crate) enum TestCommands {
|
||||
// !admin test test1
|
||||
Test1,
|
||||
}
|
||||
|
||||
|
@ -25,6 +34,7 @@ pub(crate) async fn process(command: TestCommands, _body: Vec<&str>) -> Result<R
|
|||
debug_error!("before calling test_command");
|
||||
test_command();
|
||||
debug_error!("after calling test_command");
|
||||
|
||||
RoomMessageEventContent::notice_plain(String::from("loaded"))
|
||||
},
|
||||
})
|
||||
|
|
Loading…
Add table
Reference in a new issue