Skip to main content

Crate osc94

Crate osc94 

Source
Expand description

§osc94

GitHub License GitHub Workflow Status GitHub Release GitHub Downloads (all assets, all releases) Crates.io Version Crates.io Total Downloads docs.rs

Library for handling progress bar sequences (OSC 9;4).

§💡 Example

use osc94::ProgressIteratorExt;

fn main() {
    for _ in (0..100).with_progress() {
        work();
    }
}

We’ve got you covered if you want finer control. See more examples in the examples directory, or check out the usage section below.

§📖 Usage

This library provides different levels of abstraction for working with progress bar sequences. From high-level to low-level:

  1. ProgressIteratorExt and ProgressIter: Iterator adapters for automatic progress updates. Lives under iter.rs.
  2. Progress: A struct that manages progress state and ensures proper cleanup when dropped. Lives under progress.rs.
  3. OSC94 and ProgressState: Low-level APIs for formatting progress sequences, giving you finer control over the output. Lives under raw.rs.

§🚩 Feature flags

Default features include std.

FeatureDefaultDescription
stdYesEnables Progress and iterator wrappers, which write progress sequences to std::io::Write destinations.
cliNoEnables the osc94 binary. This also enables std.

Disable default features to use the crate in no_std contexts:

osc94 = { version = "0.1", default-features = false }

With default features disabled, OSC94 and ProgressState remain available for formatting progress sequences, while Progress and iterator wrappers are not exported.

§📥 Binary

The provided binary allows you to play with progress bar sequences:

$ osc94
Sets the progress state and value of the progress bar for 1 second.

Usage: osc94 <state> <progress>

States:
  0/hidden
  1/normal
  2/error
  3/indeterminate
  4/warning

Progress: 0-100

It can be installed via the following methods:

§Using binstall

cargo binstall osc94

§Downloading from Releases

Navigate to the Releases page and download respective binary for your platform. Make sure to give it execute permissions.

§Compiling from Source

cargo install osc94 --features cli

§🎉 Credits

Re-exports§

pub use raw::OSC94;

Modules§

raw
This module is for handling raw progress bar sequence (OSC 9;4).

Structs§

Progress
A progress instance.
ProgressIter
An iterator adapter that writes OSC 9;4 progress updates while iterating.

Enums§

ProgressState
Possible states of a progress bar.

Traits§

ProgressIteratorExt
Extension trait for wrapping iterators with OSC 9;4 progress updates.