use super::generated_api::api::style::{ color::Payload as ProtobufColorPayload, Color as ProtobufColor, ColorType as ProtobufColorType, Palette as ProtobufPalette, RgbColorPayload as ProtobufRgbColorPayload, Style as ProtobufStyle, ThemeHue as ProtobufThemeHue, }; use crate::data::{Palette, PaletteColor, Style, ThemeHue}; use crate::errors::prelude::*; use std::convert::TryFrom; impl TryFrom for Style { type Error = &'static str; fn try_from(protobuf_style: ProtobufStyle) -> Result { Ok(Style { colors: protobuf_style .palette .ok_or("malformed style payload")? .try_into()?, rounded_corners: protobuf_style.rounded_corners, hide_session_name: protobuf_style.hide_session_name, }) } } impl TryFrom