forge-settings
Forge — provider settings introspection. Each provider crate exposes its configurable fields through `ProviderSettings`, letting external runtimes (TUIs, dashboards) render and edit those fields without coupling to each provider's concrete `Config` type.
Forge — provider settings introspection. Each provider crate exposes its configurable fields through ProviderSettings, letting external runtimes (TUIs, dashboards) render and edit those fields without coupling to each provider's concrete Config type.
Package contract
| Field | Value |
|---|---|
| Language | rust |
| Source version | 0.2.0 |
| Manifest | forge-rs/crates/forge-settings/Cargo.toml |
| Source files | 1 |
| Evidence | Source reference; registry publication and runtime conformance are separate checks |
Import boundary
use forge_settings;Use a source checkout or your verified private registry. Manifest coordinates identify the package; they do not establish that a public registry release exists.
Crate boundary
The following entries are taken from src/lib.rs. Feature conditions in the exact source still apply.
Source reference
Download package reference JSON. Each original source file and generated declaration artifact has its own SHA-256 digest. Function bodies and constant values are omitted from downloads. These are source declaration inventories, not compiler-resolved rustdoc, TypeDoc, DocC, or Dokka output. Private modules can contain public declarations that are not reachable through the package boundary; consult the entry point before importing.
lib.rs
Read declaration text · 14 declaration entries
#[derive(Debug, Clone, PartialEq, Eq, Serialize, Deserialize)]
pub struct ProviderSettingField {
/// Stable identifier (e.g. `"api_key"`, `"base_url"`).
pub id: String,
/// User-visible label.
pub label: String,
/// One-line description.
pub description: String,
/// What kind of value the field holds.
pub kind: ProviderSettingKind,
/// Current value, already redacted for secret fields.
pub value: String,
/// `true` when the value is sensitive — runtimes should never
/// log it and should display it as `••••••` by default.
pub secret: bool,
/// `true` when this field is the currently-active enum / picker
/// selection.
pub active: bool
}
#[must_use]
pub fn text(id: impl Into<String>, label: impl Into<String>, value: impl Into<String>) -> Self;
#[must_use]
pub fn secret_text(
id: impl Into<String>,
label: impl Into<String>,
value: impl Into<String>,
) -> Self;
#[must_use]
pub fn integer(id: impl Into<String>, label: impl Into<String>, value: i64) -> Self;
#[must_use]
pub fn boolean(id: impl Into<String>, label: impl Into<String>, value: bool) -> Self;
#[must_use]
pub fn picker(
id: impl Into<String>,
label: impl Into<String>,
current_id: impl Into<String>,
options: Vec<ProviderSettingOption>,
) -> Self;
#[must_use]
pub fn description(mut self, text: impl Into<String>) -> Self;
#[must_use]
pub fn active(mut self, on: bool) -> Self;
#[derive(Debug, Clone, PartialEq, Eq, Serialize, Deserialize)]
#[serde(tag = "kind", rename_all = "kebab-case")]
pub enum ProviderSettingKind {
/// Free-form string (api keys, urls, region names).
Text,
/// Whole-number integer (timeouts, retries).
Integer,
/// Boolean toggle.
Bool,
/// Enum picker with a fixed option list.
Picker {
/// Available choices — the runtime renders these as a sub-page.
options: Vec<ProviderSettingOption>,
},
}
#[derive(Debug, Clone, PartialEq, Eq, Serialize, Deserialize)]
pub struct ProviderSettingOption {
/// Stable identifier of the option.
pub id: String,
/// User-visible label.
pub label: String,
/// Optional one-line description.
pub description: String
}
#[must_use]
pub fn new(id: impl Into<String>, label: impl Into<String>) -> Self;
#[must_use]
pub fn description(mut self, text: impl Into<String>) -> Self;
#[derive(Debug, Clone, PartialEq, Eq, Serialize, Deserialize)]
#[serde(tag = "kind", rename_all = "kebab-case")]
pub enum FieldError {
/// The field id is not recognized by this provider.
UnknownField(String),
/// The supplied value failed validation.
InvalidValue(String),
/// The field is read-only.
ReadOnly(String),
}
pub trait ProviderSettings {
/// Stable provider identifier (e.g. `"anthropic"`, `"openai"`).
fn provider_id(&self) -> &str;
/// All fields the runtime should display, in render order.
fn fields(&self) -> Vec<ProviderSettingField>;
/// Update one field. The provider validates the value and
/// returns [`FieldError`] on rejection. Default implementation
/// returns `ReadOnly` for every field — providers that want to
/// support editing must override.
///
/// # Errors
///
/// Returns [`FieldError`] for unknown fields, invalid values, or
/// read-only fields.
fn set_field(&mut self, id: &str, _value: &str) -> Result<(), FieldError> ;
}