pub struct SettingMetadata {Show 16 fields
pub setting_type: SettingType,
pub default: Value,
pub value: Option<Value>,
pub label: String,
pub description: Option<String>,
pub options: Option<Vec<SettingOption>>,
pub min: Option<f64>,
pub max: Option<f64>,
pub step: Option<f64>,
pub placeholder: Option<String>,
pub category: Option<String>,
pub order: Option<i32>,
pub secret_storage: Option<SecretStorage>,
pub pattern: Option<String>,
pub pattern_error: Option<String>,
pub flags: SettingFlags,
}Fields§
§setting_type: SettingTypeType of setting (for UI rendering)
default: ValueDefault value
value: Option<Value>Current value (populated at runtime)
label: StringHuman-readable label
description: Option<String>Description/help text
options: Option<Vec<SettingOption>>Available options (for Select type)
min: Option<f64>Minimum value (for Number type)
max: Option<f64>Maximum value (for Number type)
step: Option<f64>Step increment (for Number type)
placeholder: Option<String>Placeholder text
category: Option<String>Category for grouping in UI
order: Option<i32>Order within category (lower = higher priority)
secret_storage: Option<SecretStorage>Where to store secret values (only used if secret=true)
pattern: Option<String>Regex pattern for validation (for Text type)
pattern_error: Option<String>Error message for pattern validation failure
flags: SettingFlagsImplementations§
Source§impl SettingMetadata
impl SettingMetadata
Sourcepub fn text(label: impl Into<String>, default: impl Into<String>) -> Self
pub fn text(label: impl Into<String>, default: impl Into<String>) -> Self
Create a text input setting
Sourcepub fn password(label: impl Into<String>, default: impl Into<String>) -> Self
pub fn password(label: impl Into<String>, default: impl Into<String>) -> Self
Create a password/secret input setting
Sourcepub fn number(label: impl Into<String>, default: impl Into<f64>) -> Self
pub fn number(label: impl Into<String>, default: impl Into<f64>) -> Self
Create a number input setting
Sourcepub fn select(
label: impl Into<String>,
default: impl Into<String>,
options: Vec<SettingOption>,
) -> Self
pub fn select( label: impl Into<String>, default: impl Into<String>, options: Vec<SettingOption>, ) -> Self
Create a select/dropdown setting
Sourcepub fn color(label: impl Into<String>, default: impl Into<String>) -> Self
pub fn color(label: impl Into<String>, default: impl Into<String>) -> Self
Create a color picker setting
Sourcepub fn path(label: impl Into<String>, default: impl Into<String>) -> Self
pub fn path(label: impl Into<String>, default: impl Into<String>) -> Self
Create a directory path selector setting
Sourcepub fn file(label: impl Into<String>, default: impl Into<String>) -> Self
pub fn file(label: impl Into<String>, default: impl Into<String>) -> Self
Create a file path selector setting
Sourcepub fn list(label: impl Into<String>, default: &[String]) -> Self
pub fn list(label: impl Into<String>, default: &[String]) -> Self
Create a list setting (Vec<String>)
Sourcepub fn description(self, desc: impl Into<String>) -> Self
pub fn description(self, desc: impl Into<String>) -> Self
Set description
Sourcepub fn options(self, opts: Vec<SettingOption>) -> Self
pub fn options(self, opts: Vec<SettingOption>) -> Self
Set options for Select type
Sourcepub fn placeholder(self, text: impl Into<String>) -> Self
pub fn placeholder(self, text: impl Into<String>) -> Self
Set placeholder text
Sourcepub fn requires_restart(self) -> Self
pub fn requires_restart(self) -> Self
Mark setting as requiring restart
Sourcepub fn secret(self) -> Self
pub fn secret(self) -> Self
⚠️ IMPORTANT: This method requires enabling one of the following features:
keychain- Store secrets in OS keychain (macOS Keychain, Windows Credential Manager, Linux Secret Service)encrypted-file- Store secrets in an encrypted file using Argon2id
Without these features, secrets will be stored in plaintext JSON, which is a security risk!
§Feature Setup
Add to your Cargo.toml:
[dependencies]
rcman = { version = "0.2", features = ["keychain"] }
# Or for encrypted file storage:
rcman = { version = "0.2", features = ["encrypted-file"] }§Compile-Time Safety
If you call .secret() without enabling the required features, you’ll get a
compile error with instructions on how to fix it. This prevents accidentally
storing secrets in plaintext.
§Example
use rcman::{settings, SettingMetadata};
use std::collections::HashMap;
settings! {
"api.key" => SettingMetadata::password("API Key", "")
.secret(), // ✅ Safe: stored in keychain or encrypted file
}Sourcepub fn pattern_error(self, msg: impl Into<String>) -> Self
pub fn pattern_error(self, msg: impl Into<String>) -> Self
Set pattern validation error message
Sourcepub fn validate(&self, value: &Value) -> Result<(), String>
pub fn validate(&self, value: &Value) -> Result<(), String>
Validate a value against this setting’s constraints
Checks:
- Number range (min/max)
- Regex pattern for text
- Valid option for select type
§Arguments
value- The value to validate
§Returns
Returns Ok(()) if validation passes, or Err(String) if validation fails.
§Errors
Returns an error string if validation fails.
Trait Implementations§
Source§impl Clone for SettingMetadata
impl Clone for SettingMetadata
Source§fn clone(&self) -> SettingMetadata
fn clone(&self) -> SettingMetadata
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read more