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.