pub struct Config {Show 20 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 media_roots: Option<Vec<String>>,
pub default_negative_prompt: Option<String>,
pub expand: ExpandSettings,
pub logging: LoggingConfig,
pub runpod: RunPodSettings,
pub lambda: LambdaSettings,
pub gpus: Option<Vec<usize>>,
pub queue_size: Option<usize>,
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).
media_roots: Option<Vec<String>>Allow roots for trusted server-local media request paths.
Override with MOLD_MEDIA_ROOTS using the platform path-list separator.
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).
lambda: LambdaSettingsLambda Cloud integration settings.
gpus: Option<Vec<usize>>GPU ordinals to use (None = all available).
queue_size: Option<usize>Max queued requests before 503 (default: 200).
models: HashMap<String, ModelConfig>Per-model configurations, keyed by model name.
Implementations§
Source§impl Config
impl Config
Sourcepub fn gpu_selection(&self) -> GpuSelection
pub fn gpu_selection(&self) -> GpuSelection
Build a GpuSelection from the config’s gpus field.
Sourcepub fn queue_size(&self) -> usize
pub fn queue_size(&self) -> usize
Return the configured queue size or the default (200).
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. When the DB-backed read hook is
installed (production path), defers to it entirely; otherwise
reads the legacy $MOLD_HOME/last-model sidecar. Callers doing
one-shot sidecar migration should use
Self::read_last_model_from_sidecar directly.
Sourcepub fn read_last_model_from_sidecar() -> Option<String>
pub fn read_last_model_from_sidecar() -> Option<String>
Read the legacy $MOLD_HOME/last-model sidecar directly. Used by
the one-shot config.toml + sidecar → DB migration.
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.
pub fn resolved_media_roots(&self) -> Vec<PathBuf>
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 resolved_placement(&self, model_name: &str) -> Option<DevicePlacement>
pub fn resolved_placement(&self, model_name: &str) -> Option<DevicePlacement>
Return the effective placement for a model: config entry plus env overrides.
Precedence (higher wins):
MOLD_PLACE_TRANSFORMER,MOLD_PLACE_VAE,MOLD_PLACE_TEXT_ENCODERS,MOLD_PLACE_T5,MOLD_PLACE_CLIP_L,MOLD_PLACE_CLIP_G,MOLD_PLACE_QWEN(env overrides per-component).- Config file
[models."name:tag".placement]table. None(use engine auto).
Each env var parses:
"auto"—DeviceRef::Auto"cpu"—DeviceRef::Cpu"gpu:N"—DeviceRef::Gpu { ordinal: N }"gpu"—DeviceRef::Gpu { ordinal: 0 }
Sourcepub fn set_model_placement(
&mut self,
model_name: &str,
placement: Option<DevicePlacement>,
)
pub fn set_model_placement( &mut self, model_name: &str, placement: Option<DevicePlacement>, )
Persist a placement for model_name, creating the model entry if
missing. None clears the placement (and leaves the rest of the
entry intact).
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 save_bootstrap_only_to(&self, path: &Path) -> Result<()>
pub fn save_bootstrap_only_to(&self, path: &Path) -> Result<()>
Serialize only the bootstrap/ops slice of the config to TOML:
identifiers, paths, ports, credentials, logging, runpod, per-model
file-path entries. User-preference fields that now live in the DB
(expand.*, generate.* globals, per-model generation defaults,
lora, scheduler) are stripped.
Used by the post-migration rewrite to keep config.toml honest
after the user-preference surface has moved to SQLite.
Sourcepub fn save_bootstrap_only(&self) -> Result<()>
pub fn save_bootstrap_only(&self) -> Result<()>
Save the bootstrap-only slice to the default config path.
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.