#[non_exhaustive]pub enum Error {
FeatureDisabled {
name: &'static str,
needed_for: &'static str,
},
PlatformUnsupported {
platform: &'static str,
},
UnknownPreset {
name: String,
known: &'static [&'static str],
},
WatchUnavailable {
reason: &'static str,
},
NoVariant {
mode: ColorMode,
},
Toml(Error),
Io {
path: PathBuf,
source: Error,
},
ResolutionIncomplete {
missing: Vec<String>,
},
ResolutionInvalid {
errors: Vec<RangeViolation>,
},
ReaderFailed {
reader: &'static str,
source: Box<dyn Error + Send + Sync>,
},
}Expand description
Errors that can occur when reading or processing theme data.
This is a flat enum with 10 variants. Use Error::kind() for coarse
dispatch without matching every variant.
Variants (Non-exhaustive)§
This enum is marked as non-exhaustive
FeatureDisabled
The platform has a theme reader, but the Cargo feature that compiles it
is not enabled (macos on macOS, windows on Windows).
Fields
PlatformUnsupported
The current platform is not supported.
UnknownPreset
A preset name was not found in the bundled set.
Fields
Theme-change watching is not available: no backend for this desktop environment, or the platform’s feature is disabled.
NoVariant
The theme has neither a light nor a dark variant.
Returned by Theme::pick_variant() and
Theme::into_variant() when the theme
has neither a light nor a dark variant set.
Toml(Error)
TOML parsing error. (Serialization errors from Theme::to_toml are
ReaderFailed with reader "toml-serializer".)
Io
A theme file could not be read.
ResolutionIncomplete
Theme resolution found missing fields that could not be inherited.
Each path, here and in RangeViolation::path, names the key a
theme author writes in TOML: button.min_height_px,
button.border.padding_left_px, defaults.icon_sizes.toolbar_px.
A path from a whole theme (Theme::resolve,
Theme::resolve_with,
SystemTheme::from_system,
SystemTheme::with_overlay)
starts with the table of the variant that failed, light. or
dark., except a layout.* key and Error::ResolutionInvalid’s
context.font_dpi, which no variant holds; a
ThemeMode resolved alone has no variant
table, so its paths start below it.
A font size is one field with two keys, size_pt and size_px (a
text-scale line height likewise, line_height_pt and
line_height_px): an out-of-range one is named by the key in the
unit its value carries, under the table the value lands in (a
button.font that inherits a defaults.font in points is
button.font.size_pt), a missing one by the field, size
(line_height).
ResolutionInvalid
Theme resolution found numeric values outside allowed ranges. Each
violation’s path is a TOML path, as Error::ResolutionIncomplete
describes, except context.font_dpi: the
ResolutionContext::font_dpi
the resolution was given, which no theme states. A DPI that is not
finite and positive is that one violation, and no field is checked.
Fields
errors: Vec<RangeViolation>One entry per out-of-range property.
ReaderFailed
A platform reader failed with a platform-specific error.
Implementations§
Trait Implementations§
Source§impl Error for Error
impl Error for Error
Source§fn source(&self) -> Option<&(dyn Error + 'static)>
fn source(&self) -> Option<&(dyn Error + 'static)>
1.0.0 · Source§fn description(&self) -> &str
fn description(&self) -> &str
use the Display impl or to_string()