Skip to main content

Config

Struct Config 

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

Top-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

Source

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.

Source

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.

Source

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 Clone for Config

Source§

fn clone(&self) -> Config

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · 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() -> Config

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

impl<'de> Deserialize<'de> for Config
where Config: Default,

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 FromStr for Config

Source§

type Err = ConfigError

The associated error which can be returned from parsing.
Source§

fn from_str(s: &str) -> Result<Self, Self::Err>

Parses a string s to return a value of this type. Read more
Source§

impl JsonSchema for Config

Source§

fn schema_name() -> Cow<'static, str>

The name of the generated JSON Schema. Read more
Source§

fn schema_id() -> Cow<'static, str>

Returns a string that uniquely identifies the schema produced by this type. Read more
Source§

fn json_schema(generator: &mut SchemaGenerator) -> Schema

Generates a JSON Schema for this type. Read more
Source§

fn inline_schema() -> bool

Whether JSON Schemas generated for this type should be included directly in parent schemas, rather than being re-used where possible using the $ref keyword. Read more
Source§

impl PartialEq for Config

Source§

fn eq(&self, other: &Config) -> bool

Tests for self and other values to be equal, and is used by ==.
1.0.0 (const: unstable) · Source§

fn ne(&self, other: &Rhs) -> bool

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
Source§

impl StructuralPartialEq for Config

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> DynClone for T
where T: Clone,

Source§

fn __clone_box(&self, _: Private) -> *mut ()

Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

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> 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<T> DeserializeOwned for T
where T: for<'de> Deserialize<'de>,