项目
在 GitHub 查看
vyfor/rattles
关于
🪇 Rust 极简终端加载动画
开发工具实测星标增长
- 24小时
- 0
- 7天
- -1
- 15天
- +3
- 1个月
- 正在收集历史
各周期内的星标净变化,周期相互重叠,并非每日新增。缺失的测量保持空白。星标代表关注度,不代表软件质量。
README.md
原文🪇 Rattles

Rattles is a minimal, dependency-free terminal spinner/throbber library for Rust. It makes no assumptions about how the output will be used.
Quick Start
cargo add rattles
Minimal example
use std::{io::Write, time::Duration};
use rattles::presets::prelude as presets;
fn main() {
let rattle = presets::waverows();
// change default interval
// let rattle = presets::waverows().set_interval(Duration::from_millis(100));
// reverse direction
// let rattle = presets::waverows().reverse();
loop {
print!("\r{}", rattle.current_frame());
std::io::stdout().flush().unwrap();
std::thread::sleep(Duration::from_millis(20));
}
}
Custom keyframes
rattle!(
Custom, // struct name
custom, // method name
1, // row count (width of the spinner)
100, // interval in milliseconds
["⣾", "⣷", "⣯", "⣟", "⣻", "⣽", "⣾"] // keyframes
)
no_std
rattles enables the std feature by default. To opt out:
cargo add rattles --no-default-features
Without std, the global clock is unavailable. Animations can still be driven three ways:
- Time-based, with an external clock:
rattle.frame_at(elapsed) - Index-based:
rattle.frame(n) - Tick-based:
Note thatlet mut rattle = presets::dots().into_ticked(); rattle.tick(); let frame = rattle.current_frame();TickedRattleris stateful and must be stored outside the render loop.
Presets
Built-in presets are organized by category:
presets::arrowspresets::asciipresets::braillepresets::emoji
A prelude is available rattles::prelude.
Examples
Acknowledgements
Rattles includes spinners sourced from these wonderful projects. We gratefully acknowledge their work.
Licensing
Dual licensed under MIT OR Apache-2.0 at your discretion. See LICENSE-MIT and LICENSE-APACHE for details.
探索相关项目
加载中…