Skip to content

Add a helper macro for parsing firefly.toml into Rust helper methods and types#23

Closed
oli-obk wants to merge 1 commit intofirefly-zero:mainfrom
oli-obk:firefly_toml_parser
Closed

Add a helper macro for parsing firefly.toml into Rust helper methods and types#23
oli-obk wants to merge 1 commit intofirefly-zero:mainfrom
oli-obk:firefly_toml_parser

Conversation

@oli-obk
Copy link

@oli-obk oli-obk commented Feb 25, 2026

I duplicated the toml data structures (they also exist in firefly-cli). While I think long term it would be good to deduplicate them, I didn't know whether/how you'd want that to be done, so I started out this way.

cheats produce a Cheat enum with a variant per cheat. The intended use case is

#[unsafe(no_mangle)]
extern "C" fn cheat(cmd: i32, val: i32) -> i32 {
    match Cheats::from_id(cmd) {
        Cheats::goto_level => {
    }
}

boards and badges produce a module with a method per board/badge. You can invoke them with boards::board_name(peer, score) or badges::the_badge(peer) to set them. If the badge's steps are not set (or 1), then there is no second argument for the badge function. Otherwise there is an argument for setting the progress.

I added unit tests, which both test that the resulting code compiles and show what the code looks like. It is ugly, but no one ever sees it (tho I could run rustfmt on it if you want). This causes a funny cyclic dependency where firefly-rust can depend on firefly-toml, whose tests again depend on firefly-rust

@oli-obk oli-obk force-pushed the firefly_toml_parser branch from 896d22f to 5d882a7 Compare February 25, 2026 12:49
@orsinium
Copy link
Member

Thank you! Moved to a separate crate:

https://github.com/firefly-zero/firefly-toml

@orsinium orsinium closed this Feb 28, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants