mirror of
https://github.com/sxyazi/yazi.git
synced 2026-07-25 08:41:05 +00:00
21 lines
491 B
Rust
21 lines
491 B
Rust
use std::str::FromStr;
|
|
|
|
use serde::Deserialize;
|
|
|
|
#[derive(Clone, Copy, Debug, Default)]
|
|
pub struct Color(ratatui::style::Color);
|
|
|
|
impl<'de> Deserialize<'de> for Color {
|
|
fn deserialize<D>(deserializer: D) -> Result<Self, D::Error>
|
|
where
|
|
D: serde::Deserializer<'de>,
|
|
{
|
|
ratatui::style::Color::from_str(&String::deserialize(deserializer)?)
|
|
.map_err(serde::de::Error::custom)
|
|
.map(Self)
|
|
}
|
|
}
|
|
|
|
impl From<Color> for ratatui::style::Color {
|
|
fn from(value: Color) -> Self { value.0 }
|
|
}
|