Struct Plugin

Source
pub struct Plugin {
    pub status_bar: StatusBar,
    pub sub_menu: Option<SubMenu>,
}
Expand description

§Example

use rust_bitbar::{Line, Plugin, SubMenu};

let mut pl = Plugin::new();
let mut line = Line::new("first line");
line.set_color("red")
    .set_href("http://google.com");

let mut sub_menu = SubMenu::new();
sub_menu.add_line(line);

let status_line = Line::new("🍺🍺🍺");
pl.set_status_line(status_line).set_sub_menu(sub_menu);

pl.render();

New returns an empty Bitbar menu without any context

Fields§

§status_bar: StatusBar§sub_menu: Option<SubMenu>

Implementations§

Source§

impl Plugin

Source

pub fn new() -> Self

Function to create empty plugin

Examples found in repository?
examples/simple.rs (line 4)
3fn main() {
4    let mut pl = Plugin::new();
5    let mut line = Line::new("first line");
6    line.set_color("red").set_href("http://google.com");
7
8    let mut sub_menu = SubMenu::new();
9    sub_menu.add_line(line);
10
11    let status_line = Line::new("🍺🍺🍺");
12    pl.set_status_line(status_line).set_sub_menu(sub_menu);
13
14    pl.render();
15}
Source

pub fn set_status_line(&mut self, line: Line) -> &mut Self

Examples found in repository?
examples/simple.rs (line 12)
3fn main() {
4    let mut pl = Plugin::new();
5    let mut line = Line::new("first line");
6    line.set_color("red").set_href("http://google.com");
7
8    let mut sub_menu = SubMenu::new();
9    sub_menu.add_line(line);
10
11    let status_line = Line::new("🍺🍺🍺");
12    pl.set_status_line(status_line).set_sub_menu(sub_menu);
13
14    pl.render();
15}
Source

pub fn set_sub_menu(&mut self, sub_menu: SubMenu) -> &mut Self

Examples found in repository?
examples/simple.rs (line 12)
3fn main() {
4    let mut pl = Plugin::new();
5    let mut line = Line::new("first line");
6    line.set_color("red").set_href("http://google.com");
7
8    let mut sub_menu = SubMenu::new();
9    sub_menu.add_line(line);
10
11    let status_line = Line::new("🍺🍺🍺");
12    pl.set_status_line(status_line).set_sub_menu(sub_menu);
13
14    pl.render();
15}
Source

pub fn render(&self)

Examples found in repository?
examples/simple.rs (line 14)
3fn main() {
4    let mut pl = Plugin::new();
5    let mut line = Line::new("first line");
6    line.set_color("red").set_href("http://google.com");
7
8    let mut sub_menu = SubMenu::new();
9    sub_menu.add_line(line);
10
11    let status_line = Line::new("🍺🍺🍺");
12    pl.set_status_line(status_line).set_sub_menu(sub_menu);
13
14    pl.render();
15}

Trait Implementations§

Source§

impl Default for Plugin

Source§

fn default() -> Plugin

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

impl ToString for Plugin

Source§

fn to_string(&self) -> String

Converts the given value to a String. Read more

Auto Trait Implementations§

§

impl Freeze for Plugin

§

impl RefUnwindSafe for Plugin

§

impl Send for Plugin

§

impl Sync for Plugin

§

impl Unpin for Plugin

§

impl UnwindSafe for Plugin

Blanket Implementations§

Source§

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

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

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

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where 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 T
where 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, U> TryFrom<U> for T
where U: Into<T>,

Source§

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 T
where U: TryFrom<T>,

Source§

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.