mirror of
https://github.com/tauri-apps/web-view.git
synced 2026-02-04 10:21:17 +01:00
* Major rewrite. - Fix unsafety (require 'static bound on dispatched closure) - Switch to builder pattern. - Run rustfmt - Fix clippy warnings - Userdata borrowed from webview instead of being arg of dispatch closure - Bump minor version - Update webview - Add crate-level doc * Add rustfmt.toml * Allow propagation of errors from invoke and dispatch closures. * Refine doc comments. * Add enum derives. * Remove mut bound from `handle()`. * Remove dependency on failure.
53 lines
982 B
Rust
53 lines
982 B
Rust
/// An RGBA color.
|
|
#[derive(Debug, Copy, Clone, Eq, PartialEq, Hash)]
|
|
pub struct Color {
|
|
pub r: u8,
|
|
pub g: u8,
|
|
pub b: u8,
|
|
pub a: u8,
|
|
}
|
|
|
|
impl From<(u8, u8, u8, u8)> for Color {
|
|
fn from(tuple: (u8, u8, u8, u8)) -> Color {
|
|
Color {
|
|
r: tuple.0,
|
|
g: tuple.1,
|
|
b: tuple.2,
|
|
a: tuple.3,
|
|
}
|
|
}
|
|
}
|
|
|
|
impl From<(u8, u8, u8)> for Color {
|
|
fn from(tuple: (u8, u8, u8)) -> Color {
|
|
Color {
|
|
r: tuple.0,
|
|
g: tuple.1,
|
|
b: tuple.2,
|
|
a: 255,
|
|
}
|
|
}
|
|
}
|
|
|
|
impl From<[u8; 4]> for Color {
|
|
fn from(array: [u8; 4]) -> Color {
|
|
Color {
|
|
r: array[0],
|
|
g: array[1],
|
|
b: array[2],
|
|
a: array[3],
|
|
}
|
|
}
|
|
}
|
|
|
|
impl From<[u8; 3]> for Color {
|
|
fn from(array: [u8; 3]) -> Color {
|
|
Color {
|
|
r: array[0],
|
|
g: array[1],
|
|
b: array[2],
|
|
a: 255,
|
|
}
|
|
}
|
|
}
|