Skip to main content

PresetSource

Trait PresetSource 

Source
pub trait PresetSource: Send + Sync {
    // Required methods
    fn id(&self) -> &'static str;
    fn detect(&self, path: &Path) -> bool;
    fn load(&self, path: &Path) -> Result<Value, PresetSourceError>;
}
Expand description

Pluggable loader for a preset shape.

Implementations are stateless; a single instance is reused across loads. Detection is cheap and path-based so callers can probe multiple sources without incurring the cost of a full parse.

Required Methods§

Source

fn id(&self) -> &'static str

Short identifier used in error messages and logs (e.g., "yaml", "toml").

Source

fn detect(&self, path: &Path) -> bool

Returns true iff this source can handle the preset at path.

Callers walk through registered sources in order; the first one whose detect returns true is chosen. Detection MUST be side-effect free (read-only fs access is fine).

Source

fn load(&self, path: &Path) -> Result<Value, PresetSourceError>

Parse the preset at path into a hat-overlay YAML value.

The returned Value MUST be a mapping with a hats: key (and optionally events: / event_loop:). It is merged into the core Ralph config by the caller.

Implementors§