You are an expert in writing code in many different languages. Your goal is to perform code completion for the following code, keeping in mind the rest of the code and the file meta data.
    Metadata details:
    filename: color.rs
    path of file: ./repos/freya/crates/state/src/values
    
    the code of the file until where you have to start completion: use crate::Parse;
use freya_engine::prelude::*;
use std::fmt;

pub trait DisplayColor {
    fn fmt_rgb(&self, f: &mut fmt::Formatter) -> fmt::Result;
    fn fmt_hsl(&self, f: &mut fmt::Formatter) -> fmt::Result;
}

#[derive(Debug, PartialEq, Eq)]
pub struct ParseColorError;

impl Parse for Color {
    type Err = ParseColorError;

    fn parse(value: &str) -> Result<Self, Self::Err> {
        match value {
            "red" => Ok(Color::RED),
            "green" => Ok(Color::GREEN),
            "blue" => Ok(Color::BLUE),
            "yellow" => Ok(Color::YELLOW),
            "black" => Ok(Color::BLACK),
            "gray" => Ok(Color::GRAY),
            "white" => Ok(Color::WHITE),
            "orange" => Ok(Color::from_rgb(255, 165, 0)),
            "transparent" => Ok(Color::TRANSPARENT),
            _ => {
                if value.starts_with("hsl(") {
                    parse_hsl(value)
                } else if value.starts_with("rgb(") {
                    parse_rgb(value)
                } else {
                    Err(ParseColorError)
                }
            }
        }
    }
}

impl DisplayColor for Color {
    fn fmt_rgb(&self, f: &mut fmt::Formatter) -> fmt::Result {
        write!(

    
fn parse_rgb(color: &str) -> Result<Color, ParseColorError> {
    if !color.ends_with(')') {
        return Err(ParseColorError);
    }

    let color = color.replacen("rgb(", "", 1).replacen(')', "", 1);

    let mut colors = color.split(',');

    let r = colors
        .next()
        .ok_or(ParseColorError)?
        .trim()
        .parse::<u8>()
        .map_err(|_| ParseColorError)?;
    let g = colors
        .next()
        .ok_or(ParseColorError)?
        .trim()
        .parse::<u8>()
        .map_err(|_| ParseColorError)?;
    let b = colors
        .next()
        .ok_or(ParseColorError)?
        .trim()
        .parse::<u8>()
        .map_err(|_| ParseColorError)?;
    let a: Option<&str> = colors.next();

    // There should not be more than 4 components.
    if colors.next().is_some() {
        return Err(ParseColorError);
    }

    if let Some(a) = a {
        let alpha_trimmed = a.trim();
        if let Ok(u8_alpha) = alpha_trimmed.parse::<u8>() {
            Ok(Color::from_argb(u8_alpha, r, g, b))
        } else if let Ok(f32_alpha) = alpha_trimmed.parse::<f32>() {
            let a = (255.0 * f32_alpha).min(255.0).max(0.0).round() as u8;
            Ok(Color::from_argb(a, r, g, b))
        } else {
            Err(ParseColorError)
        }
    } else {
        Ok(Color::from_rgb(r, g, b))
    }
}