tuna

Crates.iotuna
lib.rstuna
version0.1.0
sourcesrc
created_at2021-05-16 20:40:07.603463
updated_at2022-02-17 21:39:04.02963
descriptionTuna-bles for live-tweaking of variables, for games and other applications.
homepagehttps://github.com/tgolsson/tuna
repositoryhttps://github.com/tgolsson/tuna
max_upload_size
id398330
size26,150
Tom Solberg (tgolsson)

documentation

README

tuna

Tuna is a tool for managing CVARs during game development, as a set of global global variables, on which manipulation can be built.

At the core, the goal of tuna is to be easy to use, while avoiding unsafe code.

This is how you use it:

extern crate tuna;

const ENABLE_LOGGING: tuna::Boolean = tuna::Boolean::new("logging", "enable", false);

fn main() {
    ENABLE_LOGGING.register();

    for i in 0..10 {
	    eprintln!("xx");
        if (ENABLE_LOGGING.read()) {
            eprintln!("looping once");
        }
		if i == 5 {
		    ENABLE_LOGGING.write(true);
		}
    }
}

The register call can be omitted, at some performance cost during the first read.

There's also a utility macro to create a category more easily:

extern crate tuna;

#[tuna::tuna]
mod logging {
	pub(super) const ENABLE: bool = false;
}

fn main() {
    logging::register();

    for i in 0..10 {
        if (logging::ENABLE.read()) {
            eprintln!("looping once");
        }

		if i == 5 {
		    logging::ENABLE.write(true);
		}
    }
}

Note that tuna is a work in progress! I'm working on it due to a need, but I want to dogfood it while I build it - not build a whole thing on its own.

Alternatives:

  • cvar - much more customizable, less batteries-included
Commit count: 27

cargo fmt