SettingMetadata

Struct SettingMetadata 

Source
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: SettingType

Type of setting (for UI rendering)

§default: Value

Default value

§value: Option<Value>

Current value (populated at runtime)

§label: String

Human-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: SettingFlags

Implementations§

Source§

impl SettingMetadata

Source

pub fn text(label: impl Into<String>, default: impl Into<String>) -> Self

Create a text input setting

Source

pub fn password(label: impl Into<String>, default: impl Into<String>) -> Self

Create a password/secret input setting

Source

pub fn number(label: impl Into<String>, default: impl Into<f64>) -> Self

Create a number input setting

Source

pub fn toggle(label: impl Into<String>, default: bool) -> Self

Create a toggle/boolean setting

Source

pub fn select( label: impl Into<String>, default: impl Into<String>, options: Vec<SettingOption>, ) -> Self

Create a select/dropdown setting

Source

pub fn color(label: impl Into<String>, default: impl Into<String>) -> Self

Create a color picker setting

Source

pub fn path(label: impl Into<String>, default: impl Into<String>) -> Self

Create a directory path selector setting

Source

pub fn file(label: impl Into<String>, default: impl Into<String>) -> Self

Create a file path selector setting

Source

pub fn info(label: impl Into<String>, default: Value) -> Self

Create an info/read-only setting

Source

pub fn list(label: impl Into<String>, default: &[String]) -> Self

Create a list setting (Vec<String>)

Source

pub fn description(self, desc: impl Into<String>) -> Self

Set description

Source

pub fn options(self, opts: Vec<SettingOption>) -> Self

Set options for Select type

Source

pub fn min(self, val: f64) -> Self

Set minimum value for Number type

Source

pub fn max(self, val: f64) -> Self

Set maximum value for Number type

Source

pub fn step(self, val: f64) -> Self

Set step for Number type

Source

pub fn placeholder(self, text: impl Into<String>) -> Self

Set placeholder text

Source

pub fn requires_restart(self) -> Self

Mark setting as requiring restart

Source

pub fn category(self, cat: impl Into<String>) -> Self

Set category for grouping

Source

pub fn order(self, ord: i32) -> Self

Set display order

Source

pub fn advanced(self) -> Self

Mark setting as advanced

Source

pub fn disabled(self) -> Self

Mark setting as disabled

Source

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
}
Source

pub fn pattern(self, pattern: impl Into<String>) -> Self

Set regex pattern for validation

Source

pub fn pattern_error(self, msg: impl Into<String>) -> Self

Set pattern validation error message

Source

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

Source§

fn clone(&self) -> SettingMetadata

Returns a duplicate of the value. Read more
1.0.0 · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for SettingMetadata

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl Default for SettingMetadata

Source§

fn default() -> Self

Returns the “default value” for a type. Read more
Source§

impl<'de> Deserialize<'de> for SettingMetadata

Source§

fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>
where __D: Deserializer<'de>,

Deserialize this value from the given Serde deserializer. Read more
Source§

impl Serialize for SettingMetadata

Source§

fn serialize<__S>(&self, __serializer: __S) -> Result<__S::Ok, __S::Error>
where __S: Serializer,

Serialize this value into the given Serde serializer. Read more

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

Source§

fn vzip(self) -> V

Source§

impl<T> DeserializeOwned for T
where T: for<'de> Deserialize<'de>,