Struct rsbadges::Badge

source ·
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.

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");

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.

Trait Implementations§

source§

impl Clone for Badge

source§

fn clone(&self) -> Badge

Returns a copy of the value. Read more
1.0.0 · source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
source§

impl Debug for Badge

source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
source§

impl Default for Badge

source§

fn default() -> Badge

Returns the “default value” for a type. Read more

Auto Trait Implementations§

§

impl RefUnwindSafe for Badge

§

impl Send for Badge

§

impl Sync for Badge

§

impl Unpin for Badge

§

impl UnwindSafe for Badge

Blanket Implementations§

source§

impl<T> Any for Twhere T: 'static + ?Sized,

source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
source§

impl<T> Borrow<T> for Twhere T: ?Sized,

source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
source§

impl<T> BorrowMut<T> for Twhere T: ?Sized,

source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
source§

impl<T> From<T> for T

source§

fn from(t: T) -> T

Returns the argument unchanged.

source§

impl<T, U> Into<U> for Twhere U: From<T>,

source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

source§

impl<T> ToOwned for Twhere T: Clone,

§

type Owned = T

The resulting type after obtaining ownership.
source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
source§

impl<T, U> TryFrom<U> for Twhere U: Into<T>,

§

type Error = Infallible

The type returned in the event of a conversion error.
source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
source§

impl<T, U> TryInto<U> for Twhere U: TryFrom<T>,

§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
§

impl<V, T> VZip<V> for Twhere V: MultiLane<T>,

§

fn vzip(self) -> V