Skip to main content

Module config

Module config 

Source
Expand description

Configuration access for plugins.

Provides ergonomic wrappers around the host config interface.

§Example

use zlayer_sdk::config;

// Get optional config
if let Some(value) = config::get("my_key") {
    log::info(&format!("Got value: {}", value));
}

// Get required config
let required = config::get_required("database.host")?;

// Get typed values
let port = config::get_int("database.port").unwrap_or(5432);
let enabled = config::get_bool("feature.enabled").unwrap_or(false);

Functions§

exists
Check if a configuration key exists.
get
Get a configuration value by key.
get_all
Get all configuration as a JSON string (for debugging).
get_bool
Get a configuration value as a boolean.
get_float
Get a configuration value as a float.
get_int
Get a configuration value as an integer.
get_many
Get multiple configuration values at once.
get_prefix
Get all configuration keys with a given prefix.
get_required
Get a configuration value, returning an error if not found.