9 releases

✓ Uses Rust 2018 edition

new 0.3.3 Mar 25, 2020
0.3.2 Mar 24, 2020
0.3.0 Jan 19, 2020
0.2.1 Jan 18, 2020
0.1.1 Aug 20, 2019

#34 in Asynchronous

Download history 11/week @ 2019-12-02 95/week @ 2019-12-09 1/week @ 2019-12-16 5/week @ 2019-12-23 56/week @ 2020-01-13 18/week @ 2020-01-20 1/week @ 2020-01-27 6/week @ 2020-02-03 8/week @ 2020-02-10 20/week @ 2020-02-17 38/week @ 2020-02-24 1/week @ 2020-03-02 18/week @ 2020-03-09 38/week @ 2020-03-16

91 downloads per month


856 lines

Welcome to cursive-async-view 👋

stable build nightly build crates.io Docs.rs GitHub PRs Welcome
A loading-screen wrapper for gyscos/cursive views

This project provides a wrapper view with a loading screen for gyscos/cursive views. The loading screen will disappear once the wrapped view is fully loaded. This is useful for displaying views which may take long to construct or depend on e.g. the network.

How does it look like? demo terminalizer

Expand to view async-view-simple demo async-view-progress demo async-view-timeout demo async-view-progress-fail demo


Simply add to your Cargo.toml

cursive-async-view = "^0"

Asynchronous view loading without progress information

If you can't tell the progress during a long taking preparation of data for a view, you may wrap the creation of this view in an AsyncView. This will display a loading animation until the inner view is ready to be drawn.

use std::time::{Instant, Duration};
use cursive::{views::TextView, Cursive};
use cursive_async_view::{AsyncView, AsyncState};

let mut siv = Cursive::default();
let instant = Instant::now();
let async_view = AsyncView::new(&mut siv, move || {
    if instant.elapsed() > Duration::from_secs(10) {
            TextView::new("Yay!\n\nThe content has loaded!")
    } else {

// siv.run();

Refer to the AsyncView struct level documentation for a detailed explanation or to the simple example located in the source code repository.

If you need to do a blocking operation during the construction of the child view, you may have a look at the alternate new_with_bg_task constructor.

use std::thread;
use std::time::Duration;

use cursive::views::TextView;
use cursive::Cursive;
use cursive_async_view::AsyncView;

let mut siv = Cursive::default();
let async_view = AsyncView::new_with_bg_creator(&mut siv, move || {
    // this function is executed in a background thread, so we can block
    // here as long as we like

    // enough blocking, let's show the content
    Ok("Yeet! It worked 🖖")
}, TextView::new); // create a text view from the string

// siv.run();

Refer to the AsyncView struct level documentation for a detailed explanation or to the bg_task example located in the source code repository.

Asynchronous view loading with a progress bar

If you have information about the progress a long taking view creation has made, you can wrap the creation in an AsyncProgressView. This will display a progress bar until the inner view is ready to be drawn.

use cursive::{views::TextView, Cursive};
use cursive_async_view::{AsyncProgressView, AsyncProgressState};

let mut siv = Cursive::default();
let start = std::time::Instant::now();
let async_view = AsyncProgressView::new(&mut siv, move || {
    if start.elapsed().as_secs() < 3 {
        AsyncProgressState::Pending(start.elapsed().as_secs() as f32 / 3f32)
    } else {
        AsyncProgressState::Available(TextView::new("Finally it loaded!"))

// siv.run();


The changelog is located in a separate file and contains changes and migration hints for upcoming versions.


If you find any bugs/unexpected behaviour or you have a proposition for future changes open an issue describing the current behaviour and what you expected.

Development cargo test


Running the tests

Just run

$ cargo test

to execute all available tests.

shields.io endpoints

shields.io endpoints are generated inside the ./target/shields folder. They are used in this README.


Fin Christensen

:octocat: @fin-ger
🐘 @fin_ger@weirder.earth
🐦 @fin_ger_github

Johannes Wünsche

:octocat: @jwuensche
🐘 @fredowald@mastodon.social
🐦 @Fredowald

Show your support

Give a ⭐ if this project helped you!


~77K SLoC