{"id":19016160,"url":"https://github.com/fosskers/linya","last_synced_at":"2025-04-06T06:13:17.855Z","repository":{"id":40241543,"uuid":"320913053","full_name":"fosskers/linya","owner":"fosskers","description":"Simple concurrent progress bars.","archived":false,"fork":false,"pushed_at":"2024-09-14T22:40:00.000Z","size":236,"stargazers_count":103,"open_issues_count":2,"forks_count":8,"subscribers_count":3,"default_branch":"master","last_synced_at":"2025-03-30T04:11:10.467Z","etag":null,"topics":["progress-bar","rust"],"latest_commit_sha":null,"homepage":"","language":"Rust","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/fosskers.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":null,"funding":".github/FUNDING.yml","license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null},"funding":{"github":"fosskers","custom":"https://www.buymeacoffee.com/fosskers"}},"created_at":"2020-12-12T19:59:20.000Z","updated_at":"2024-11-16T07:48:13.000Z","dependencies_parsed_at":"2024-09-15T06:24:39.841Z","dependency_job_id":"14671fca-a6f6-4a42-bea6-ecfb9dbe390f","html_url":"https://github.com/fosskers/linya","commit_stats":{"total_commits":67,"total_committers":3,"mean_commits":"22.333333333333332","dds":"0.10447761194029848","last_synced_commit":"db73aae48e8b335c6135ecff7c1aed92e038da01"},"previous_names":[],"tags_count":6,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/fosskers%2Flinya","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/fosskers%2Flinya/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/fosskers%2Flinya/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/fosskers%2Flinya/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/fosskers","download_url":"https://codeload.github.com/fosskers/linya/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":247441059,"owners_count":20939239,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["progress-bar","rust"],"created_at":"2024-11-08T19:41:29.587Z","updated_at":"2025-04-06T06:13:17.824Z","avatar_url":"https://github.com/fosskers.png","language":"Rust","funding_links":["https://github.com/sponsors/fosskers","https://www.buymeacoffee.com/fosskers"],"categories":[],"sub_categories":[],"readme":"# linya\n\n[![Workflow Status](https://github.com/fosskers/linya/workflows/Tests/badge.svg)](https://github.com/fosskers/linya/actions?query=workflow%3A%22Tests%22)\n[![](https://img.shields.io/crates/v/linya.svg)](https://crates.io/crates/linya)\n\nSimple concurrent progress bars.\n\n![](https://github.com/fosskers/linya/blob/master/screenshots/multi.gif?raw=true)\n\n## Features\n\n- Intuitive API.\n- First-class support for `rayon`, etc.\n- Efficient, allocation-free redraws.\n- Addition of new subbars on-the-fly.\n- Single-threaded multi-bars.\n- Light-weight, only a single dependency.\n\n## Usage\n\n`linya` is designed around the multi-bar case, and unlike other progress bar\nlibraries, has no separate type for individual bars. Instead, we use the\n`Progress` type, a \"bar coordinator\".\n\n### Multi Bars\n\nTo mutably access a `Progress` across threads it must be wrapped in the\nusual [concurrent sharing types][arcmutex]. With `rayon` specifically, only\n`Mutex` is necessary:\n\n```rust\nuse std::sync::Mutex;\nuse linya::{Bar, Progress};\nuse rayon::prelude::*;\n\nlet progress = Mutex::new(Progress::new());\n\n// `into_par_iter()` is from `rayon`, and lets us parallelize some\n// operation over a collection \"for free\".\n(0..10).into_par_iter().for_each(|n| {\n  let bar: Bar = progress.lock().unwrap().bar(50, format!(\"Downloading {}\", n));\n\n  // ... Your logic ...\n\n  // Increment the bar and draw it immediately.\n  // This is likely called in some inner loop or other closure.\n  progress.lock().unwrap().inc_and_draw(\u0026bar, 10);\n});\n```\n\nNotice that new bars are added on-the-fly from within forked threads. We\ncall `Progress::bar` to obtain a new \"bar handle\", and then pass that\nhandle back to the parent `Progress` when incrementing/drawing.\n\nSee `Progress::inc_and_draw` and `Progress::set_and_draw` to advance and\nrender the bars.\n\n### Single Bars\n\n`Progress` can also be used in a single-threaded context for individual\nbars. The usage is the same, except that no locking is required:\n\n```rust\nuse linya::{Bar, Progress};\n\nlet mut progress = Progress::new();\nlet bar: Bar = progress.bar(50, \"Downloading\");\n\n// Use in a loop, etc.\nprogress.set_and_draw(\u0026bar, 10);\n```\n\nIn this way, you could even have multi-bars in a single-threaded context.\n\n## Caveats\n\nSome of the points below may be fixed in future releases.\n\n- Your terminal must support ANSI codes.\n- No dedicated render thread, to keep usage simple.\n- No bar templating, to avoid dependencies.\n- No other bar styling ([yet]).\n- No \"rates\", since rerenders are not time-based.\n- No bar clearing after completion.\n- No spinners, also due to no sense of time.\n- No dynamic resizing of bars if window size changes.\n\nIf you need more customizable progress bars and are willing to accept\nheavier dependencies, please consider [indicatif].\n\nNote also that using more than one `Progress` at the same time leads to\nunspecified behaviour.\n\n## Trivia\n\n_Linya_ is the Quenya word for \"pool\", as in a [beautiful mountain pool][mirrormere].\n\n[mirrormere]: https://www.tednasmith.com/tolkien/durins-crown-and-the-mirrormere/\n[arcmutex]: https://doc.rust-lang.org/stable/book/ch16-03-shared-state.html?#atomic-reference-counting-with-arct\n[yet]: https://internals.rust-lang.org/t/fmt-dynamic-fill-character/13609\n[indicatif]: https://lib.rs/crates/indicatif\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ffosskers%2Flinya","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Ffosskers%2Flinya","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ffosskers%2Flinya/lists"}