Struct widgetui::app::App

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

The powerhouse of tui-helper, runs all defined widgets for you at a set framerate

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/minimal.rs (line 17)
16
17
18
fn main() -> Result<(), Box<dyn Error>> {
    App::new(100)?.with_widget(widget).run()
}
More examples
Hide additional examples
examples/custom_chunk.rs (line 41)
40
41
42
43
44
45
46
fn main() -> Result<(), Box<dyn Error>> {
    App::new(100)?
        .handle_panics()
        .with_widget(chunk_generator)
        .with_widget(render)
        .run()
}
examples/custom_state.rs (line 38)
37
38
39
40
41
42
43
fn main() -> Result<(), Box<dyn Error>> {
    App::new(100)?
        .with_state(CustomState { state: 0 })
        .with_widget(handle_state)
        .handle_panics()
        .run()
}
examples/message.rs (line 47)
46
47
48
49
50
51
52
53
fn main() -> Result<(), Box<dyn Error>> {
    App::new(100)?
        .handle_panics()
        .with_widget(chunk_builder)
        .with_widget(my_widget)
        .with_set(Message)
        .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 42)
40
41
42
43
44
45
46
fn main() -> Result<(), Box<dyn Error>> {
    App::new(100)?
        .handle_panics()
        .with_widget(chunk_generator)
        .with_widget(render)
        .run()
}
More examples
Hide additional examples
examples/custom_state.rs (line 41)
37
38
39
40
41
42
43
fn main() -> Result<(), Box<dyn Error>> {
    App::new(100)?
        .with_state(CustomState { state: 0 })
        .with_widget(handle_state)
        .handle_panics()
        .run()
}
examples/message.rs (line 48)
46
47
48
49
50
51
52
53
fn main() -> Result<(), Box<dyn Error>> {
    App::new(100)?
        .handle_panics()
        .with_widget(chunk_builder)
        .with_widget(my_widget)
        .with_set(Message)
        .run()
}
source

pub fn with_widget<I, W: Widget + 'static>( self, widget: impl IntoWidget<I, Widget = W> + 'static ) -> Self

Add a widget to the system

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

pub fn with_state<S: Any>(self, state: S) -> Self

Add a state to the system

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)?
        .with_state(CustomState { state: 0 })
        .with_widget(handle_state)
        .handle_panics()
        .run()
}
source

pub fn with_set(self, set: impl Set) -> Self

Add a set to the system

Examples found in repository?
examples/message.rs (line 51)
46
47
48
49
50
51
52
53
fn main() -> Result<(), Box<dyn Error>> {
    App::new(100)?
        .handle_panics()
        .with_widget(chunk_builder)
        .with_widget(my_widget)
        .with_set(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/minimal.rs (line 17)
16
17
18
fn main() -> Result<(), Box<dyn Error>> {
    App::new(100)?.with_widget(widget).run()
}
More examples
Hide additional examples
examples/custom_chunk.rs (line 45)
40
41
42
43
44
45
46
fn main() -> Result<(), Box<dyn Error>> {
    App::new(100)?
        .handle_panics()
        .with_widget(chunk_generator)
        .with_widget(render)
        .run()
}
examples/custom_state.rs (line 42)
37
38
39
40
41
42
43
fn main() -> Result<(), Box<dyn Error>> {
    App::new(100)?
        .with_state(CustomState { state: 0 })
        .with_widget(handle_state)
        .handle_panics()
        .run()
}
examples/message.rs (line 52)
46
47
48
49
50
51
52
53
fn main() -> Result<(), Box<dyn Error>> {
    App::new(100)?
        .handle_panics()
        .with_widget(chunk_builder)
        .with_widget(my_widget)
        .with_set(Message)
        .run()
}

Auto Trait Implementations§

§

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 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, 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.