#[non_exhaustive]pub enum TintedBuilderError {
SchemeMissingProperty(String),
YamlDeserialize(Error),
RibboncurlsRender(RibboncurlsError),
ColorRadix(ParseIntError),
HexInputFormat,
InvalidSchemeVariant(String),
InvalidSchemeSystem(String),
}Expand description
Add tinted-builder library test since tinted-builder-rust is exporting the structs
use tinted_builder_rust::{Scheme, Template};
let template = String::from(r#"/* Some CSS file with {{scheme-name}} theme */
.someCssSelector { background-color: #{{base00-hex}} }
.someOtherCssSelector { background-color: #{{base0F-hex}} }"#);
let scheme_str = r#"system: "base16"
name: "UwUnicorn"
author: "Fernando Marques (https://github.com/RakkiUwU) and Gabriel Fontes (https://github.com/Misterio77)"
variant: "dark"
palette:
base00: "241b26"
base01: "2f2a3f"
base02: "46354a"
base03: "6c3cb2"
base04: "7e5f83"
base05: "eed5d9"
base06: "d9c2c6"
base07: "e4ccd0"
base08: "877bb6"
base09: "de5b44"
base0A: "a84a73"
base0B: "c965bf"
base0C: "9c5fce"
base0D: "6a9eb5"
base0E: "78a38f"
base0F: "a3a079""#;
let scheme = Scheme::Base16(serde_yaml::from_str(&scheme_str).unwrap());
let template = Template::new(template, scheme);
let output = template
.render()
.unwrap();
assert_eq!(output, r#"/* Some CSS file with UwUnicorn theme */
.someCssSelector { background-color: #241b26 }
.someOtherCssSelector { background-color: #a3a079 }"#);An error type representing the various errors that can occur when using tinted-builder
This error type is non-exhaustive, meaning additional variants may be added in future versions without it being considered a breaking change. The enum variants cover a range of possible issues that might arise during the processing of color schemes, including missing properties, deserialization errors, and rendering issues.
Variants (Non-exhaustive)§
This enum is marked as non-exhaustive
SchemeMissingProperty(String)
Error indicating that a required property in the scheme is missing.
This variant is used when a necessary property for the scheme’s configuration is not found.
YamlDeserialize(Error)
Error that occurs when YAML deserialization fails.
This variant wraps the serde_yaml::Error and is used when there is an issue converting
a YAML string into the corresponding Rust data structure.
RibboncurlsRender(RibboncurlsError)
Error that occurs during rendering using Ribboncurls.
This variant wraps the RibboncurlsError and is used when an error is encountered while
rendering a template or other content using Ribboncurls.
ColorRadix(ParseIntError)
Error that occurs when a string slice cannot be converted to an integer with the given base.
This variant wraps std::num::ParseIntError and is used when a string slice, such as a color
value in hexadecimal format, fails to parse correctly.
HexInputFormat
Error indicating that a hex color input is not formatted correctly.
This variant is used when a color string that is expected to be in hex format does not match the expected format.
InvalidSchemeVariant(String)
Error indicating that an invalid scheme variant was provided.
This variant is used when an input string does not correspond to any valid scheme variant, such as “dark” or “light”.
InvalidSchemeSystem(String)
Error indicating that an invalid scheme system was provided.
This variant is used when an input string does not correspond to any valid scheme system