fn handle_style_change(&mut self, body: &Value) {
        #[derive(Deserialize, Debug)]
        struct Event {
            id: StyleID,
            #[serde(default)]
            italic: bool,
            fg_color: Option<u32>,
            bg_color: Option<u32>,
        }

        let event: Event = serde_json::from_value(body.clone()).unwrap();

        // fg
        let fg_color = event.fg_color.map(|fg| {
            let rgba = fg.to_le_bytes();
            RGBColor {
                r: rgba[0],
                g: rgba[1],
                b: rgba[2],
            }
        });

        let bg_color = event.bg_color.map(|bg| {
            let rgba = bg.to_le_bytes();
            RGBColor {
                r: rgba[0],
                g: rgba[1],
                b: rgba[2],
            }
        });

        self.styles
            .borrow_mut()
            .save(event.id, fg_color, bg_color, event.italic);
    }
/// Handle the "def_style" event.
///
/// This function need to create a new set of background/foreground and save
/// it with the given id.
Handle the "def_style" event.
This function need to create a new set of background/foreground and save
it with the given id.
Handle the " def_style " event . This function need to create a new set of background / foreground and save it with the given id .
fn handle_style_change(&mut self, body: &Value) {
        #[derive(Deserialize, Debug)]
        struct Event {
            id: StyleID,
            #[serde(default)]
            italic: bool,
            fg_color: Option<u32>,
            bg_color: Option<u32>,
        }
        let event: Event = serde_json::from_value(body.clone()).unwrap();
        // fg
        let fg_color = event.fg_color.map(|fg| {
            let rgba = fg.to_le_bytes();
            RGBColor {
                r: rgba[0],
                g: rgba[1],
                b: rgba[2],
            }
        });
        let bg_color = event.bg_color.map(|bg| {
            let rgba = bg.to_le_bytes();
            RGBColor {
                r: rgba[0],
                g: rgba[1],
                b: rgba[2],
            }
        });
        self.styles
            .borrow_mut()
            .save(event.id, fg_color, bg_color, event.italic);
    }
fn handle_style_change ( & mut self , body : & Value ) { # [ derive ( Deserialize Debug ) ] struct Event { id : StyleID , # [ serde ( default ) ] italic : bool , fg_color : Option < u32 > , bg_color : Option < u32 > , } let event : Event = serde_json :: from_value ( body . clone ( ) ) . unwrap ( ) ; // fg let fg_color = event . fg_color . map ( | fg | { let rgba = fg . to_le_bytes ( ) ; RGBColor { r : rgba [ 0 ] , g : rgba [ 1 ] , b : rgba [ 2 ] , } } ) ; let bg_color = event . bg_color . map ( | bg | { let rgba = bg . to_le_bytes ( ) ; RGBColor { r : rgba [ 0 ] , g : rgba [ 1 ] , b : rgba [ 2 ] , } } ) ; self . styles . borrow_mut ( ) . save ( event . id , fg_color , bg_color , event . italic ) ; }
Handle the "def_style" event.
Handle the " def_style " event .
&mut self
body
&Value
&mut self
body
&Value