[−][src]Crate const_tweaker
Runtime const
tweaking
This library starts a web server at http://127.0.0.1:9938
where you can change the values of const
variables in your crate.
f64
& bool
are the types that are currently supported.
Example
// Tweak `VALUE` when running in debug mode // This will render a slider in the web GUI because the type here is a `f64` #[const_tweaker::tweak] const VALUE: f64 = 0.0; fn main() -> Result<(), Box<dyn std::error::Error>> { // Initialize the server at 'http://127.0.0.1:9938' when running in debug mode #[cfg(debug_assertions)] const_tweaker::run()?; // Enter a GUI/Game loop loop { // ... // Print the constant value that can be changed from the website. println!("VALUE: {}", VALUE); } Ok(()) }
Some widgets have customizable options, as seen in the examples below:
f64
:
// Spawns a slider #[const_tweaker::tweak] const DEFAULT_VALUE: f64 = 0.0; // Spawns a slider with 10 steps from 0-1 #[const_tweaker::tweak(min = 0.0, max = 1.0, step = 0.1)] const CUSTOM_VALUE: f64 = 0.0;
bool
:
// Spawns a checkbox #[const_tweaker::tweak] const DEFAULT_VALUE: bool = true;
&str
// Spaws a textbox #[const_tweaker::tweak] const DEFAULT_VALUE: &str = "Hi";
Functions
run | Launch the |
Attribute Macros
tweak | Expose a const variable to the web GUI so it can be changed from a live setting. |