use thiserror::Error;
#[derive(Debug, Clone)]
pub struct Badge {
pub label_text: String,
pub label_color: String,
pub label_link: String,
pub msg_text: String,
pub msg_color: String,
pub msg_link: String,
pub logo: String,
pub embed_logo: bool,
pub badge_link: String,
pub badge_title: String,
pub label_title: String,
pub msg_title: String,
}
impl Default for Badge {
fn default() -> Badge {
Badge {
label_text: String::from("test"),
msg_text: String::from("test"),
badge_link: String::from(""),
label_link: String::from(""),
msg_link: String::from(""),
label_color: String::from("#555"),
msg_color: String::from("#007ec6"),
logo: String::from(""),
embed_logo: false,
badge_title: String::from(""),
label_title: String::from(""),
msg_title: String::from(""),
}
}
}
#[derive(Default, Debug)]
pub(crate) struct Layout {
pub label_text_norm: String,
pub msg_text_norm: String,
pub badge_height: f32,
pub label_text_width: f32,
pub msg_text_width: f32,
pub label_total_width: f32,
pub msg_total_width: f32,
pub label_text_x: f32,
pub msg_text_x: f32,
pub msg_bubble_x: f32,
pub label_rect_width: f32,
pub msg_rect_width: f32,
pub logo_padding: f32,
pub logo_width: f32,
pub logo_x: f32,
pub logo_y: f32,
pub label_color: String,
pub msg_color: String,
}
#[derive(Error, Debug, PartialEq)]
pub enum BadgeError {
#[error("Unable to parse command line arguments. {0}")]
BadCommandLineArgs(String),
#[error("The provided color {0} is not a valid CSS color format.")]
ColorNotValid(String),
#[error("Unable to save the badge SVG to {0}.")]
CannotSaveToFile(String),
#[error("Unable to download and embed the logo. Attempted to load from {0}.")]
CannotEmbedLogo(String),
#[error("Unable to find the font file.")]
CannotLocateFont,
#[error("Unable to load the font file.")]
CannotLoadFont,
#[error(
"{0} is an invalid style. Valid styles: \n- plastic\n- flat\n- flatsquare.\n\
- forthebadge\n- social"
)]
InvalidStyle(String),
}