Skip to content

tgolsson/tuna

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

27 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

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:

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

fn main() {
    ENABLE_LOGGING.register();

    loop {
        if (ENABLE_LOGGING.read()) {
            eprintln!("looping once");
        }
    }
}

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

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
  • const-tweaker - similar in workflow to tuna + tuna-web, unfortunately suffers from soundness issues.

About

No description, website, or topics provided.

Resources

License

Apache-2.0, MIT licenses found

Licenses found

Apache-2.0
LICENSE-APACHE
MIT
LICENSE-MIT

Stars

Watchers

Forks

Packages

No packages published