pub struct IconGenerator { /* private fields */ }Expand description
Builder API for composing multiple TOML icon definitions.
Implementations§
Source§impl IconGenerator
impl IconGenerator
Sourcepub fn base_dir(self, path: impl AsRef<Path>) -> Self
pub fn base_dir(self, path: impl AsRef<Path>) -> Self
Set the base directory for theme resolution.
When set, all theme directories (e.g., material/, sf-symbols/) are
resolved relative to this path instead of the parent directory of each
TOML source file.
When not set and multiple sources have different parent directories,
generate() returns an error.
Sourcepub fn crate_path(self, path: &str) -> Self
pub fn crate_path(self, path: &str) -> Self
Set the Rust crate path prefix used in generated code.
Defaults to "native_theme". When the default is used, the generated
file includes extern crate native_theme; to support Cargo aliases.
Set this to a custom path (e.g. "my_crate::native_theme") when
re-exporting native-theme from another crate.
Sourcepub fn derive(self, name: &str) -> Self
pub fn derive(self, name: &str) -> Self
Add an extra #[derive(...)] trait to the generated enum.
The base set (Debug, Clone, Copy, PartialEq, Eq, Hash) is always
emitted. Each call appends one additional derive.
native_theme_build::IconGenerator::new()
.source("icons/icons.toml")
.derive("Ord")
.derive("serde::Serialize")
.generate()
.unwrap_or_exit();Sourcepub fn output_dir(self, path: impl AsRef<Path>) -> Self
pub fn output_dir(self, path: impl AsRef<Path>) -> Self
Set an explicit output directory for the generated .rs file.
When not set, the OUT_DIR environment variable is used (always
available during cargo build). Set this when running outside of
a build script context (e.g., in integration tests).
Sourcepub fn generate(self) -> Result<GenerateOutput, BuildErrors>
pub fn generate(self) -> Result<GenerateOutput, BuildErrors>
Run the full pipeline: load, validate, generate.
Returns a GenerateOutput on success or BuildErrors on failure.
Call GenerateOutput::emit_cargo_directives() on the result to write
the generated file and emit cargo directives.
Source paths may be absolute or relative. Relative paths are resolved
against CARGO_MANIFEST_DIR. When all source paths are absolute,
CARGO_MANIFEST_DIR is not required.
§Errors
Returns BuildErrors if CARGO_MANIFEST_DIR is not set and a
relative source path is used, or if neither
output_dir() nor OUT_DIR is set.