a8m / pb

Console progress bar for Rust

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Add support for setting/changing total after creation

jonhoo opened this issue · comments

In some cases, like HTTP downloads (see progress_function in libcurl for example), you may not know the size of the download until after you have been in touch with the remote server. But you may still want to create the progress bar to show that things are happening. Once the connection is established, and the Content-Length header has been received, the total for the progress bar can be set, and progress can be logged.

It'd be great if pb offered a way to create a new, "indeterminate" progress bar, and then allow for the total to be set afterwards.

Just for the record: you CAN change total afterwards (the struct field is directly accessible). Call tick manually afterwards if you don't also change the current value (inc, set, add).

I didn't test it, but I guess you can also change the show_* fields in a similar fashion, e.g. only start showing a timer later.

What did you try so far?

Was this only an issue in an older version?