Struct widgetui::app::App

source ·
pub struct App { /* private fields */ }
Expand description

The powerhouse of widgetui, runs all defined widgets for you

Implementations§

source§

impl App

source

pub fn new(clock: u64) -> Result<Self, Box<dyn Error>>

Create a new app with the given clock time (in ms)

Examples found in repository?
examples/custom_set.rs (line 46)
45
46
47
fn main() -> Result<(), Box<dyn Error>> {
    App::new(100)?.sets(CoolSet).run()
}
More examples
Hide additional examples
examples/minimal.rs (line 19)
18
19
20
fn main() -> Result<(), Box<dyn Error>> {
    App::new(100)?.widgets(widget).run()
}
examples/custom_chunk.rs (line 42)
41
42
43
44
45
46
fn main() -> Result<(), Box<dyn Error>> {
    App::new(100)?
        .handle_panics()
        .widgets((chunk_generator, render))
        .run()
}
examples/message.rs (line 43)
42
43
44
45
46
47
48
fn main() -> Result<(), Box<dyn Error>> {
    App::new(100)?
        .handle_panics()
        .widgets((chunk_builder, my_widget))
        .sets(Message)
        .run()
}
examples/custom_state.rs (line 38)
37
38
39
40
41
42
43
fn main() -> Result<(), Box<dyn Error>> {
    App::new(100)?
        .states(CustomState { state: 0 })
        .widgets(handle_state)
        .handle_panics()
        .run()
}
source

pub fn handle_panics(self) -> Self

Running this will ensure that any panic that happens, this will catch And prevent your terminal from messing up.

Examples found in repository?
examples/custom_chunk.rs (line 43)
41
42
43
44
45
46
fn main() -> Result<(), Box<dyn Error>> {
    App::new(100)?
        .handle_panics()
        .widgets((chunk_generator, render))
        .run()
}
More examples
Hide additional examples
examples/message.rs (line 44)
42
43
44
45
46
47
48
fn main() -> Result<(), Box<dyn Error>> {
    App::new(100)?
        .handle_panics()
        .widgets((chunk_builder, my_widget))
        .sets(Message)
        .run()
}
examples/custom_state.rs (line 41)
37
38
39
40
41
42
43
fn main() -> Result<(), Box<dyn Error>> {
    App::new(100)?
        .states(CustomState { state: 0 })
        .widgets(handle_state)
        .handle_panics()
        .run()
}
source

pub fn widgets<I, T>(self, widget: impl IntoWidgetSet<I, T>) -> Self

Adds the following Widgets to the system. This will take in a tuple of widgets, or a single widget.

Examples found in repository?
examples/minimal.rs (line 19)
18
19
20
fn main() -> Result<(), Box<dyn Error>> {
    App::new(100)?.widgets(widget).run()
}
More examples
Hide additional examples
examples/custom_chunk.rs (line 44)
41
42
43
44
45
46
fn main() -> Result<(), Box<dyn Error>> {
    App::new(100)?
        .handle_panics()
        .widgets((chunk_generator, render))
        .run()
}
examples/message.rs (line 45)
42
43
44
45
46
47
48
fn main() -> Result<(), Box<dyn Error>> {
    App::new(100)?
        .handle_panics()
        .widgets((chunk_builder, my_widget))
        .sets(Message)
        .run()
}
examples/custom_state.rs (line 40)
37
38
39
40
41
42
43
fn main() -> Result<(), Box<dyn Error>> {
    App::new(100)?
        .states(CustomState { state: 0 })
        .widgets(handle_state)
        .handle_panics()
        .run()
}
source

pub fn widget<W: Widget + 'static>(self, widget: W) -> Self

source

pub fn states<S: MultiFromStates>(self, state: S) -> Self

Add the following states to the system This will take in a state or a tuple of states.

Examples found in repository?
examples/custom_state.rs (line 39)
37
38
39
40
41
42
43
fn main() -> Result<(), Box<dyn Error>> {
    App::new(100)?
        .states(CustomState { state: 0 })
        .widgets(handle_state)
        .handle_panics()
        .run()
}
source

pub fn sets(self, set: impl Sets) -> Self

Add a set to the system

Examples found in repository?
examples/custom_set.rs (line 46)
45
46
47
fn main() -> Result<(), Box<dyn Error>> {
    App::new(100)?.sets(CoolSet).run()
}
More examples
Hide additional examples
examples/message.rs (line 46)
42
43
44
45
46
47
48
fn main() -> Result<(), Box<dyn Error>> {
    App::new(100)?
        .handle_panics()
        .widgets((chunk_builder, my_widget))
        .sets(Message)
        .run()
}
source

pub fn run(self) -> Result<(), Box<dyn Error>>

Run the app, returning an error if any of the functions error out.

Examples found in repository?
examples/custom_set.rs (line 46)
45
46
47
fn main() -> Result<(), Box<dyn Error>> {
    App::new(100)?.sets(CoolSet).run()
}
More examples
Hide additional examples
examples/minimal.rs (line 19)
18
19
20
fn main() -> Result<(), Box<dyn Error>> {
    App::new(100)?.widgets(widget).run()
}
examples/custom_chunk.rs (line 45)
41
42
43
44
45
46
fn main() -> Result<(), Box<dyn Error>> {
    App::new(100)?
        .handle_panics()
        .widgets((chunk_generator, render))
        .run()
}
examples/message.rs (line 47)
42
43
44
45
46
47
48
fn main() -> Result<(), Box<dyn Error>> {
    App::new(100)?
        .handle_panics()
        .widgets((chunk_builder, my_widget))
        .sets(Message)
        .run()
}
examples/custom_state.rs (line 42)
37
38
39
40
41
42
43
fn main() -> Result<(), Box<dyn Error>> {
    App::new(100)?
        .states(CustomState { state: 0 })
        .widgets(handle_state)
        .handle_panics()
        .run()
}

Auto Trait Implementations§

§

impl Freeze for App

§

impl !RefUnwindSafe for App

§

impl !Send for App

§

impl !Sync for App

§

impl Unpin for App

§

impl !UnwindSafe for App

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> IntoEither for T

source§

fn into_either(self, into_left: bool) -> Either<Self, Self>

Converts self into a Left variant of Either<Self, Self> if into_left is true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
where F: FnOnce(&Self) -> bool,

Converts self into a Left variant of Either<Self, Self> if into_left(&self) returns true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
source§

impl<T, U> TryFrom<U> for T
where 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 T
where 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.