Skip to content
ํ”„๋กœ์ ํŠธ

์†Œ๊ฐœ

๐Ÿช‡ Rust์šฉ ๋ฏธ๋‹ˆ๋ฉ€ ํ„ฐ๋ฏธ๋„ ์Šคํ”ผ๋„ˆ/๋กœ๋”ฉ ํ‘œ์‹œ

๊ฐœ๋ฐœ ๋„๊ตฌ

์ด ์ˆ˜์น˜๋ฅผ ์ธก์ •ํ•˜๋Š” ๋ฐฉ๋ฒ•

์ธก์ •๋œ ์Šคํƒ€ ์ฆ๊ฐ€

in 24h
0
in 7 days
-1
in 15 days
+3
in 1 month
๊ธฐ๋ก ์ˆ˜์ง‘ ์ค‘

์„œ๋กœ ๊ฒน์น˜๋Š” ๊ธฐ๊ฐ„์˜ ์ˆœ์ฆ๊ฐ€๋Ÿ‰์ด๋ฉฐ ์ผ๋ณ„ ํ•ฉ๊ณ„๊ฐ€ ์•„๋‹™๋‹ˆ๋‹ค. ์ธก์ •๊ฐ’์ด ์—†์œผ๋ฉด ๋น„์›Œ ๋‘ก๋‹ˆ๋‹ค. ์Šคํƒ€๋Š” ๊ด€์‹ฌ๋„๋ฅผ ๋‚˜ํƒ€๋‚ด๋ฉฐ ํ’ˆ์งˆ์„ ๋ณด์žฅํ•˜์ง€ ์•Š์Šต๋‹ˆ๋‹ค.

README.md

Original

๐Ÿช‡ Rattles

Demo

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:
    let mut rattle = presets::dots().into_ticked();
    rattle.tick();
    let frame = rattle.current_frame();
    
    Note that TickedRattler is stateful and must be stored outside the render loop.

Presets

Built-in presets are organized by category:

  • presets::arrows
  • presets::ascii
  • presets::braille
  • presets::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.

๊ด€๋ จ ํ”„๋กœ์ ํŠธ ์‚ดํŽด๋ณด๊ธฐ

๋ถˆ๋Ÿฌ์˜ค๋Š” ์ค‘โ€ฆ