pub struct Config {
pub line: Option<LineConfig>,
pub theme: Option<String>,
pub layout: LayoutMode,
pub layout_options: Option<LayoutOptions>,
pub segments: BTreeMap<String, SegmentOverride>,
pub plugin_dirs: Vec<PathBuf>,
pub preset: Option<String>,
pub plugins: Option<BTreeMap<String, Value>>,
pub schema_url: Option<String>,
}Expand description
Parsed config.toml. Serde ignores unknown keys so a file from a
newer linesmith still parses on an older binary; fields this
version doesn’t know are dropped rather than rejected. The
schema-side additionalProperties: false tightens editor
validation so typos like thme = "default" get flagged at the
authoring layer; the runtime stays permissive (the unknown-key
warning channel lives in from_str_validated).
Fields§
§line: Option<LineConfig>§theme: Option<String>§layout: LayoutModeTop-level layout mode. Defaults to LayoutMode::SingleLine
when the field is omitted, preserving pre-multi-line config
behavior. LayoutMode::MultiLine triggers per-[line.N]
rendering.
layout_options: Option<LayoutOptions>§segments: BTreeMap<String, SegmentOverride>§plugin_dirs: Vec<PathBuf>Extra directories to scan for user plugin scripts (.rhai
files). Scanned in list order before the default XDG
directory. See docs/specs/config.md §Plugin directories and
docs/specs/plugin-api.md §Plugin file location.
preset: Option<String>Spec-listed forward-compat key. Parsed and runtime-ignored;
surfacing it in the schema so editor tooling doesn’t flag
user configs that include it. Allow-listed in KNOWN_TOP_LEVEL
to suppress the unknown-key warning.
plugins: Option<BTreeMap<String, Value>>Forward-compat [plugins.*] table. Typed as a string-keyed
map so a non-table value (plugins = "oops") fails parse at
load-time instead of silently dropping; per-plugin sub-table
shape is open until the plugin-config spec lands. Schema
mirror remaps toml::Value to serde_json::Value for the
same reason as extra / numbered: toml::Value has no
JsonSchema impl.
schema_url: Option<String>Editor-tooling $schema directive. Some users put it as a
top-level TOML key instead of (or alongside) the #:schema
comment directive linesmith init writes. Must be quoted in
TOML ("$schema" = "...") — $ is not legal in bare keys.
Parsed and ignored at runtime; surfaced here so the schema
validates configs using the alternate form.
Implementations§
Source§impl Config
impl Config
Sourcepub fn load(path: &Path) -> Result<Option<Self>, ConfigError>
pub fn load(path: &Path) -> Result<Option<Self>, ConfigError>
Read and parse the file at path. Returns Ok(None) when the
file doesn’t exist (normal case for first-run users); other I/O
errors propagate so callers can log them. Unknown keys are
silently ignored — callers that want typo warnings use
Config::load_validated instead.
Sourcepub fn load_validated(
path: &Path,
warn: impl FnMut(&str),
) -> Result<Option<Self>, ConfigError>
pub fn load_validated( path: &Path, warn: impl FnMut(&str), ) -> Result<Option<Self>, ConfigError>
Same as Config::load but emits one warning per unknown key
encountered (top-level, [layout_options], or [segments.<id>]).
The allow-list tolerates every spec-documented key (see
KNOWN_TOP_LEVEL and KNOWN_LAYOUT_OPTIONS), so forward-compat
configs stay silent while typos surface.
Sourcepub fn from_str_validated(
s: &str,
warn: impl FnMut(&str),
) -> Result<Self, ConfigError>
pub fn from_str_validated( s: &str, warn: impl FnMut(&str), ) -> Result<Self, ConfigError>
FromStr-equivalent with unknown-key warnings. The plain
FromStr impl remains the non-validating form; validation is
opt-in so callers that don’t want the allow-list surface (unit
tests, programmatic config construction) bypass it.
Trait Implementations§
Source§impl<'de> Deserialize<'de> for Config
impl<'de> Deserialize<'de> for Config
Source§fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
Source§impl JsonSchema for Config
impl JsonSchema for Config
Source§fn schema_id() -> Cow<'static, str>
fn schema_id() -> Cow<'static, str>
Source§fn json_schema(generator: &mut SchemaGenerator) -> Schema
fn json_schema(generator: &mut SchemaGenerator) -> Schema
Source§fn inline_schema() -> bool
fn inline_schema() -> bool
$ref keyword. Read more