Feature toggles in Rust (with Admin Web UI)

Hello everybody :slight_smile:

I've just published my first Rust crate: an implementation of feature toggles for Rust:

https://crates.io/crates/feattle

It was an intense battle with the macro syntax for some weekends, but I feel like it was worth it. In your code you can declare the features like:

feattles! {
    struct SimulationToggles {
        /// Activates extruding the mesh terrain, usually in the minor inertia axis.
        extrude_mesh_terrain: bool,
        /// The domestic module being always present, requires some balancing.
        balance_domestic_coefficients: u8 = 17,
        /// When to pause the bucolic routine to wonder about future capital availability
        calculate_money_supply: CalculateMoneySupply = CalculateMoneySupply::EveryNowAndThen,
        /// Some entities will respond to some links only
        map_influence_attributes: BTreeMap<Uuid, MapInfluenceAttributes> = default_map_influence_attributes(),
        /// A boolean, or not, for more chaos.
        iterate_chaos_array: Option<bool>,
    }
}

With some support code to define the update strategy with the underlying storage, you can then simply read their values like:

if *my_toggles.balance_domestic_coefficients() > 27 {
    todo!()
}

You also get a dark-cool admin UI to modify their values in run-time:

All that very flexible and extensible, so that it is easy to adjust to different projects. Hope it is useful for someone!

7 Likes

Hey, that's pretty neat. :slight_smile: