pub struct Config {Show 16 fields
pub config_version: u32,
pub default_model: String,
pub models_dir: String,
pub server_port: u16,
pub default_width: u32,
pub default_height: u32,
pub default_steps: u32,
pub embed_metadata: bool,
pub t5_variant: Option<String>,
pub qwen3_variant: Option<String>,
pub output_dir: Option<String>,
pub default_negative_prompt: Option<String>,
pub expand: ExpandSettings,
pub logging: LoggingConfig,
pub runpod: RunPodSettings,
pub models: HashMap<String, ModelConfig>,
}Fields§
§config_version: u32Config schema version for migrations. Old configs without this field default to 0 and are migrated on first load.
default_model: String§models_dir: String§server_port: u16§default_width: u32§default_height: u32§default_steps: u32§embed_metadata: bool§t5_variant: Option<String>Preferred T5 encoder variant: “fp16” (default), “q8”, “q6”, “q5”, “q4”, “q3”, or “auto”. “auto” selects the best variant that fits in GPU VRAM. An explicit quantized tag always uses that variant regardless of VRAM.
qwen3_variant: Option<String>Preferred Qwen3 text encoder variant: “bf16” (default), “q8”, “q6”, “iq4”, “q3”, or “auto”. “auto” selects the best variant that fits in GPU VRAM (with drop-and-reload).
output_dir: Option<String>Directory to persist generated images. Default: ~/.mold/output/.
Override with MOLD_OUTPUT_DIR env var. Set to empty string to disable
(TUI gallery will not function when disabled).
default_negative_prompt: Option<String>Global default negative prompt for CFG-based models (SD1.5, SDXL, SD3, Wuerstchen).
Overridden by per-model negative_prompt or CLI --negative-prompt.
expand: ExpandSettingsPrompt expansion settings.
logging: LoggingConfigLogging configuration.
runpod: RunPodSettingsRunPod integration settings (api key, defaults, auto-teardown behaviour).
models: HashMap<String, ModelConfig>Per-model configurations, keyed by model name.
Implementations§
Source§impl Config
impl Config
pub fn install_runtime_models_dir_override(models_dir: PathBuf)
pub fn load_or_default() -> Self
Sourcepub fn reload_from_disk_preserving_runtime(&self) -> Self
pub fn reload_from_disk_preserving_runtime(&self) -> Self
Reload config from disk while preserving runtime-only overrides.
Sourcepub fn mold_dir() -> Option<PathBuf>
pub fn mold_dir() -> Option<PathBuf>
The root mold directory.
Resolution: MOLD_HOME env var → ~/.mold/ → ./.mold (if HOME unset).
pub fn config_path() -> Option<PathBuf>
pub fn data_dir() -> Option<PathBuf>
pub fn resolved_models_dir(&self) -> PathBuf
pub fn has_models_dir_override(&self) -> bool
Sourcepub fn resolved_default_model(&self) -> String
pub fn resolved_default_model(&self) -> String
Resolve the effective default model with idiot-proof fallback chain:
MOLD_DEFAULT_MODELenv var (if set and non-empty)- Config file
default_model(if that model has a custom[models]entry) - Config file
default_model(if that model is a known manifest model that is downloaded) - Last-used model from
$MOLD_HOME/last-model(if downloaded) - If exactly one model is downloaded, use it automatically
- Fall back to config value (will trigger auto-pull on use)
Sourcepub fn resolve_default_model(&self) -> DefaultModelResolution
pub fn resolve_default_model(&self) -> DefaultModelResolution
Like [resolved_default_model] but also returns which fallback step resolved it.
Sourcepub fn read_last_model() -> Option<String>
pub fn read_last_model() -> Option<String>
Read the last-used model name from the state file.
Sourcepub fn write_last_model(model: &str)
pub fn write_last_model(model: &str)
Write the last-used model name to the state file (best-effort, non-fatal).
Sourcepub fn resolved_output_dir(&self) -> Option<PathBuf>
pub fn resolved_output_dir(&self) -> Option<PathBuf>
Resolve the output directory for server-mode image persistence.
MOLD_OUTPUT_DIR env var takes precedence over the config file value.
Returns None when disabled (default).
Sourcepub fn is_output_disabled(&self) -> bool
pub fn is_output_disabled(&self) -> bool
Check if image output has been explicitly disabled by the user
(empty MOLD_OUTPUT_DIR env var or empty output_dir config field).
Sourcepub fn effective_output_dir(&self) -> PathBuf
pub fn effective_output_dir(&self) -> PathBuf
Resolved output directory with a default fallback to ~/.mold/output/.
Unlike resolved_output_dir(), this always returns a path.
Sourcepub fn resolved_log_dir(&self) -> PathBuf
pub fn resolved_log_dir(&self) -> PathBuf
Resolved log directory from config or default (~/.mold/logs/).
pub fn effective_embed_metadata(&self, override_value: Option<bool>) -> bool
pub fn discovered_manifest_paths(&self, name: &str) -> Option<ModelPaths>
pub fn manifest_model_is_downloaded(&self, name: &str) -> bool
Sourcepub fn manifest_model_needs_download(&self, name: &str) -> bool
pub fn manifest_model_needs_download(&self, name: &str) -> bool
Return true when a known manifest-backed model is missing any required
downloadable asset and should be repaired with mold pull.
Sourcepub fn model_config(&self, name: &str) -> ModelConfig
pub fn model_config(&self, name: &str) -> ModelConfig
Return the ModelConfig for a given model name, or an empty default.
Tries the exact name first, then the canonical name:tag form.
Sourcepub fn resolved_model_config(&self, name: &str) -> ModelConfig
pub fn resolved_model_config(&self, name: &str) -> ModelConfig
Return a model config merged with manifest defaults and metadata.
Sourcepub fn upsert_model(&mut self, name: String, config: ModelConfig)
pub fn upsert_model(&mut self, name: String, config: ModelConfig)
Insert or update a model configuration entry.
Sourcepub fn remove_model(&mut self, name: &str) -> Option<ModelConfig>
pub fn remove_model(&mut self, name: &str) -> Option<ModelConfig>
Remove a model entry from the config, returning it if it existed.
Sourcepub fn save(&self) -> Result<()>
pub fn save(&self) -> Result<()>
Write the config to disk at config_path().
Safety: refuses to save if models_dir points to a temp/test directory,
which can happen when tests race on the MOLD_HOME env var.
Sourcepub fn exists_on_disk() -> bool
pub fn exists_on_disk() -> bool
Whether a config file exists on disk.
Sourcepub fn lookup_model_config(&self, name: &str) -> Option<ModelConfig>
pub fn lookup_model_config(&self, name: &str) -> Option<ModelConfig>
Look up a model config entry by name (exact or canonical name:tag form).
Public so CLI commands can check whether a model has a custom config entry.