Skip to main content

Config

Struct Config 

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

Config 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: ExpandSettings

Prompt expansion settings.

§logging: LoggingConfig

Logging configuration.

§runpod: RunPodSettings

RunPod integration settings (api key, defaults, auto-teardown behaviour).

§models: HashMap<String, ModelConfig>

Per-model configurations, keyed by model name.

Implementations§

Source§

impl Config

Source

pub fn install_runtime_models_dir_override(models_dir: PathBuf)

Source

pub fn load_or_default() -> Self

Source

pub fn reload_from_disk_preserving_runtime(&self) -> Self

Reload config from disk while preserving runtime-only overrides.

Source

pub fn mold_dir() -> Option<PathBuf>

The root mold directory. Resolution: MOLD_HOME env var → ~/.mold/./.mold (if HOME unset).

Source

pub fn config_path() -> Option<PathBuf>

Source

pub fn data_dir() -> Option<PathBuf>

Source

pub fn resolved_models_dir(&self) -> PathBuf

Source

pub fn has_models_dir_override(&self) -> bool

Source

pub fn resolved_default_model(&self) -> String

Resolve the effective default model with idiot-proof fallback chain:

  1. MOLD_DEFAULT_MODEL env var (if set and non-empty)
  2. Config file default_model (if that model has a custom [models] entry)
  3. Config file default_model (if that model is a known manifest model that is downloaded)
  4. Last-used model from $MOLD_HOME/last-model (if downloaded)
  5. If exactly one model is downloaded, use it automatically
  6. Fall back to config value (will trigger auto-pull on use)
Source

pub fn resolve_default_model(&self) -> DefaultModelResolution

Like [resolved_default_model] but also returns which fallback step resolved it.

Source

pub fn read_last_model() -> Option<String>

Read the last-used model name from the state file.

Source

pub fn write_last_model(model: &str)

Write the last-used model name to the state file (best-effort, non-fatal).

Source

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).

Source

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).

Source

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.

Source

pub fn resolved_log_dir(&self) -> PathBuf

Resolved log directory from config or default (~/.mold/logs/).

Source

pub fn effective_embed_metadata(&self, override_value: Option<bool>) -> bool

Source

pub fn discovered_manifest_paths(&self, name: &str) -> Option<ModelPaths>

Source

pub fn manifest_model_is_downloaded(&self, name: &str) -> bool

Source

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.

Source

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.

Source

pub fn resolved_model_config(&self, name: &str) -> ModelConfig

Return a model config merged with manifest defaults and metadata.

Source

pub fn upsert_model(&mut self, name: String, config: ModelConfig)

Insert or update a model configuration entry.

Source

pub fn remove_model(&mut self, name: &str) -> Option<ModelConfig>

Remove a model entry from the config, returning it if it existed.

Source

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.

Source

pub fn exists_on_disk() -> bool

Whether a config file exists on disk.

Source

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.

Trait Implementations§

Source§

impl Clone for Config

Source§

fn clone(&self) -> Config

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 Config

Source§

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

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

impl Default for Config

Source§

fn default() -> Self

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

impl<'de> Deserialize<'de> for Config

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 Config

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> Instrument for T

Source§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
Source§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
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> PolicyExt for T
where T: ?Sized,

Source§

fn and<P, B, E>(self, other: P) -> And<T, P>
where T: Policy<B, E>, P: Policy<B, E>,

Create a new Policy that returns Action::Follow only if self and other return Action::Follow. Read more
Source§

fn or<P, B, E>(self, other: P) -> Or<T, P>
where T: Policy<B, E>, P: Policy<B, E>,

Create a new Policy that returns Action::Follow if either self or other returns Action::Follow. Read more
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> WithSubscriber for T

Source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

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