pub enum Style {
Plastic(Badge),
Flat(Badge),
FlatSquare(Badge),
ForTheBadge(Badge),
Social(Badge),
}
Expand description
A badge container used to format and generate a badge SVG.
As the Badge struct holds generic badge data, the Style enum instructs how to
generate that data into a badge SVG. There are currently five Styles: Plastic
,
Flat
, FlatSquare
, ForTheBadge
, and Social
. This naming follows the convention set by
Shields.io.
Once a Style object has been instantiated, a badge can be created using the
generate_svg
function.
Examples
use rsbadges::{Badge, Style};
let badge = Badge {
label_text: String::from("Custom_label"),
msg_text: String::from("Custom_msg"),
..Badge::default()
};
// Create a plastic badge using the data created above.
let badge_style = Style::Plastic(badge);
let badge_svg = badge_style.generate_svg();
// Save this to file with rsbadges::save_svg
Variants§
Plastic(Badge)
The “plastic” badge style
Flat(Badge)
The “flat” badge style
FlatSquare(Badge)
The “flat square” badge style
ForTheBadge(Badge)
The “for the badge” badge style
Social(Badge)
The “social” badge style
Implementations§
source§impl Style
impl Style
sourcepub fn generate_svg(&self) -> Result<String, BadgeError>
pub fn generate_svg(&self) -> Result<String, BadgeError>
Generates an SVG from the badge data in the chosen badge style.
Badges are lazily evaluated; that is, the data in the Badge struct is not verified until a badge is generated using this function.
Errors
Since this is where data verification takes place, a number of errors are possible:
See BadgeError for a full description of each.