Skip to content

Commit

Permalink
clippy
Browse files Browse the repository at this point in the history
  • Loading branch information
amrbashir committed Oct 24, 2024
1 parent 46a861b commit eb82252
Show file tree
Hide file tree
Showing 6 changed files with 22 additions and 14 deletions.
1 change: 1 addition & 0 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

8 changes: 4 additions & 4 deletions crates/tauri-cli/config.schema.json
Original file line number Diff line number Diff line change
Expand Up @@ -843,7 +843,7 @@
"InnerColor": {
"anyOf": [
{
"description": "A tuple of RGB colors. Each value has minimum of 0 and maximum of 255.",
"description": "Array of RGB colors. Each value has minimum of 0 and maximum of 255.",
"type": "array",
"items": [
{
Expand All @@ -866,7 +866,7 @@
"minItems": 3
},
{
"description": "A tuple of RGBA colors. Each value has minimum of 0 and maximum of 255.",
"description": "Array of RGBA colors. Each value has minimum of 0 and maximum of 255.",
"type": "array",
"items": [
{
Expand Down Expand Up @@ -894,7 +894,7 @@
"minItems": 4
},
{
"description": "An object of red, green, blue, alpha color values. Each value has minimum of 0 and maximum of 255.",
"description": "Object of red, green, blue, alpha color values. Each value has minimum of 0 and maximum of 255.",
"type": "object",
"required": [
"blue",
Expand Down Expand Up @@ -926,7 +926,7 @@
}
},
{
"description": "A color hex string, for example: #fff, #ffffff, or #ffffffff.",
"description": "Color hex string, for example: #fff, #ffffff, or #ffffffff.",
"type": "string"
}
]
Expand Down
2 changes: 1 addition & 1 deletion crates/tauri-runtime-wry/src/window/windows.rs
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ impl super::WindowExt for tao::window::Window {
surface.resize(width, height).unwrap();
let mut buffer = surface.buffer_mut().unwrap();
let color = background_color
.map(|(r, g, b, _)| ((b as u32) << 0) | ((g as u32) << 8) | ((r as u32) << 16))
.map(|(r, g, b, _)| (b as u32) | ((g as u32) << 8) | ((r as u32) << 16))
.unwrap_or(0);
buffer.fill(color);
let _ = buffer.present();
Expand Down
8 changes: 4 additions & 4 deletions crates/tauri-schema-generator/schemas/config.schema.json
Original file line number Diff line number Diff line change
Expand Up @@ -843,7 +843,7 @@
"InnerColor": {
"anyOf": [
{
"description": "A tuple of RGB colors. Each value has minimum of 0 and maximum of 255.",
"description": "Array of RGB colors. Each value has minimum of 0 and maximum of 255.",
"type": "array",
"items": [
{
Expand All @@ -866,7 +866,7 @@
"minItems": 3
},
{
"description": "A tuple of RGBA colors. Each value has minimum of 0 and maximum of 255.",
"description": "Array of RGBA colors. Each value has minimum of 0 and maximum of 255.",
"type": "array",
"items": [
{
Expand Down Expand Up @@ -894,7 +894,7 @@
"minItems": 4
},
{
"description": "An object of red, green, blue, alpha color values. Each value has minimum of 0 and maximum of 255.",
"description": "Object of red, green, blue, alpha color values. Each value has minimum of 0 and maximum of 255.",
"type": "object",
"required": [
"blue",
Expand Down Expand Up @@ -926,7 +926,7 @@
}
},
{
"description": "A color hex string, for example: #fff, #ffffff, or #ffffffff.",
"description": "Color hex string, for example: #fff, #ffffff, or #ffffffff.",
"type": "string"
}
]
Expand Down
3 changes: 2 additions & 1 deletion crates/tauri-utils/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@ log = "0.4.21"
cargo_metadata = { version = "0.18", optional = true }
serde-untagged = "0.1"
uuid = { version = "1", features = ["serde"] }
once_cell = { version = "1", optional = true }

[target."cfg(target_os = \"macos\")".dependencies]
swift-rs = { version = "1.0.7", optional = true, features = ["build"] }
Expand All @@ -57,7 +58,7 @@ serial_test = "3.1"
[features]
build = ["proc-macro2", "quote", "cargo_metadata", "schema", "swift-rs"]
compression = ["brotli"]
schema = ["schemars"]
schema = ["schemars", "once_cell"]
isolation = ["aes-gcm", "getrandom", "serialize-to-javascript"]
process-relaunch-dangerous-allow-symlink-macos = []
config-json5 = ["json5"]
Expand Down
14 changes: 10 additions & 4 deletions crates/tauri-utils/src/config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1323,23 +1323,29 @@ fn default_alpha() -> u8 {
255
}

#[cfg(feature = "schema")]
static HEX_COLOR_RE: once_cell::sync::Lazy<regex::Regex> = once_cell::sync::Lazy::new(|| {
regex::Regex::new(r"^#?([A-Fa-f0-9]{3}|[A-Fa-f0-9]{6}|[A-Fa-f0-9]{8})$").unwrap()
});

#[derive(Deserialize)]
#[cfg_attr(feature = "schema", derive(JsonSchema))]
#[serde(untagged)]
enum InnerColor {
/// A tuple of RGB colors. Each value has minimum of 0 and maximum of 255.
/// Array of RGB colors. Each value has minimum of 0 and maximum of 255.
Rgb((u8, u8, u8)),
/// A tuple of RGBA colors. Each value has minimum of 0 and maximum of 255.
/// Array of RGBA colors. Each value has minimum of 0 and maximum of 255.
Rgba((u8, u8, u8, u8)),
/// An object of red, green, blue, alpha color values. Each value has minimum of 0 and maximum of 255.
/// Object of red, green, blue, alpha color values. Each value has minimum of 0 and maximum of 255.
RgbaObject {
red: u8,
green: u8,
blue: u8,
#[serde(default = "default_alpha")]
alpha: u8,
},
/// A color hex string, for example: #fff, #ffffff, or #ffffffff.
/// Color hex string, for example: #fff, #ffffff, or #ffffffff.
#[cfg_attr(feature = "schema", validate(regex(path = *HEX_COLOR_RE)))]
String(String),
}

Expand Down

0 comments on commit eb82252

Please sign in to comment.