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,
}
Expand description
Holds generic info about a badge.
The Badge struct holds all of the options that could be set for a badge SVG. It is meant to be as superficial as possible; errors are checked on the generation of the SVG itself, not the Badge object.
Since there are so many options, it’s recommended that one use the default()
method
during initialization to make the process less verbose:
let badge = Badge {
label_text: String::from("Custom_label"),
msg_text: String::from("Custom_msg"),
..Badge::default()
};
Fields§
§label_text: String
The text to show on the left side of the badge.
label_color: String
The background color of the left side of the badge.
This argument takes any valid CSS color code. See the CSS color picker for examples.
// All of these formats would work for `label_text`
let valid_rgb_color = String::from("rgb(40, 20, 50)");
let valid_hsl_color = String::from("hsl(15, 100%, 50%)");
let valid_hex_color = String::from("#00bfff");
let valid_html_color = String::from("white");
label_link: String
The url to redirect to when the left side of the badge is clicked.
msg_text: String
The text to show on the right side of the badge.
msg_color: String
The background color of the right side of the badge. See label_text for more info.
msg_link: String
The url to redirect to when the right side of the badge is clicked.
logo: String
A URI reference to a logo to display in the badge. Must be in SVG format.
This argument will accept both logo URLs and local logo files. Visit https://simpleicons.org/ for a rich library of icons to choose from.
// Both of these options would work for `logo`
let logo_url = String::from("https://simpleicons.org/icons/rust.svg");
let logo_local = String::from("~/Downloads/rust.svg");
embed_logo: bool
Include the specified logo data directly in the badge. This prevents a URL call whenever the SVG is loaded. Only works if logo is a HTTP/HTTPS URI or a valid file path.
When validating the logo, RSBadges looks for the file on your local machine, and if that fails, it makes an attempt to download.
Success in either case causes the logo’s data to be injected into the badge SVG directly. This means the logo can be seen regardless of the logo file being present or retrievable.
badge_link: String
The url to redirect to when any part of the badge is clicked. Overwrites –label-link and –msg-link.
badge_title: String
The title to associate with the entire badge. More info here.
label_title: String
The title to associate with the left side of the badge.
msg_title: String
The title to associate with the right side of the badge.