Struct abar::StatusBlock[][src]

pub struct StatusBlock { /* fields omitted */ }
Expand description

Encapsulates a Fn() -> String closure.

Each StatusBlock has a unique name, some command that returns a string, and a polling interval. The result of the command will be cached, and will be updated iff the update() method is called and the time since the last update is > the polling interval.

Building

StatusBlocks follow the builder pattern for instantiation, so to make a new one you might use something like this:

let block = StatusBlock::new()
    .name("example")
    .command(&|| "hello".to_string())
    .poll_interval(Duration::from_secs(5));

Implementations

Returns a new StatusBlock with default values. The defaults are:

StatusBlock {
    name:          String::new(),
    command:       Box::new(|| String::new()),
    poll_interval: None,
}

Returns a reference to the name of the StatusBlock.

Returns a reference to the StatusBlocks’s cache.

Iff the StatusBlock needs to be updated, update it.

Auto Trait Implementations

Blanket Implementations

Gets the TypeId of self. Read more

Immutably borrows from an owned value. Read more

Mutably borrows from an owned value. Read more

Performs the conversion.

Performs the conversion.

The type returned in the event of a conversion error.

Performs the conversion.

The type returned in the event of a conversion error.

Performs the conversion.