add dynamic config
This commit is contained in:
@@ -7,6 +7,6 @@ edition = "2024"
|
|||||||
http-body-util = "0.1.3"
|
http-body-util = "0.1.3"
|
||||||
hyper = { version = "1.6.0", features = ["full"] }
|
hyper = { version = "1.6.0", features = ["full"] }
|
||||||
hyper-util = { version = "0.1.11", features = ["full"] }
|
hyper-util = { version = "0.1.11", features = ["full"] }
|
||||||
serde = "1.0.219"
|
serde = { version = "1.0.219", features = ["derive"] }
|
||||||
tokio = { version = "1.44.2", features = ["full"] }
|
tokio = { version = "1.44.2", features = ["full"] }
|
||||||
toml = "0.8.22"
|
toml = "0.8.22"
|
||||||
|
31
theseus-server/src/config.rs
Normal file
31
theseus-server/src/config.rs
Normal file
@@ -0,0 +1,31 @@
|
|||||||
|
use std::net::SocketAddr;
|
||||||
|
use serde::Deserialize;
|
||||||
|
|
||||||
|
macro_rules! def_config {
|
||||||
|
($(config $config_id: ident
|
||||||
|
{ $([$namespace: ident $struct_name: ident]$($var_id: ident = $var_type: ty),*)*$(,)? })*
|
||||||
|
) => {
|
||||||
|
$(
|
||||||
|
#[derive(Deserialize)]
|
||||||
|
pub struct $config_id {
|
||||||
|
$(pub $namespace: $struct_name),*
|
||||||
|
}
|
||||||
|
|
||||||
|
$(
|
||||||
|
#[derive(Deserialize)]
|
||||||
|
pub struct $struct_name { $(pub $var_id: $var_type),* }
|
||||||
|
)*
|
||||||
|
)*
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
def_config! {
|
||||||
|
|
||||||
|
config Config {
|
||||||
|
|
||||||
|
[server Server]
|
||||||
|
bind_to = SocketAddr, // where to bind the server tcp socket in format: "<host>:<port>"
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
Reference in New Issue
Block a user