Module ark_api::feature_toggle

source ·
Expand description

🎚 Feature toggle API

This API lets you define your own feature toggles, and read them from a module.

Feature toggles need to be declared in the Cargo.toml of your module, in a metadata section specific to Ark. For instance, this allows declaring a feature toggle called developer-mode, that’s defaulting to false, with a small description that will used for display in the Ark client.

[package.metadata.ark.feature-toggles.developer-mode]
default = false
description = "this is the description that will be shown in the Ark client's UI"

Feature toggle names must start with an ASCII letter. Other characters may include ASCII alphanumericals or dashes or underscores.

To read the value of a specific feature toggle, use the get() function provided by this module.

Example:

ark::require_feature_toggle_api!();

fn myfunc() {
    let is_set: bool = ark::feature_toggle::get("my-feature-toggle");
}

Functions

  • Reads the value for a feature toggle predefined in the package’s metadata.