{"id":16915663,"url":"https://github.com/zesterer/pollster","last_synced_at":"2025-05-15T05:07:55.545Z","repository":{"id":37246419,"uuid":"253815152","full_name":"zesterer/pollster","owner":"zesterer","description":"A minimal async executor that lets you block on a future","archived":false,"fork":false,"pushed_at":"2025-02-01T20:28:36.000Z","size":67,"stargazers_count":579,"open_issues_count":3,"forks_count":21,"subscribers_count":11,"default_branch":"master","last_synced_at":"2025-04-14T08:11:37.463Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"","language":"Rust","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"apache-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/zesterer.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":null,"funding":".github/FUNDING.yml","license":"LICENSE-APACHE","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,"zenodo":null},"funding":{"github":["zesterer"]}},"created_at":"2020-04-07T14:18:29.000Z","updated_at":"2025-04-11T12:55:53.000Z","dependencies_parsed_at":"2024-06-18T18:37:22.091Z","dependency_job_id":"eecf9157-7dc3-42cf-a460-e71ff643569a","html_url":"https://github.com/zesterer/pollster","commit_stats":{"total_commits":39,"total_committers":7,"mean_commits":5.571428571428571,"dds":0.5384615384615384,"last_synced_commit":"767e6dbabbf93131ad9e7a8935e7a69974e3fd4c"},"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/zesterer%2Fpollster","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/zesterer%2Fpollster/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/zesterer%2Fpollster/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/zesterer%2Fpollster/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/zesterer","download_url":"https://codeload.github.com/zesterer/pollster/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":254276447,"owners_count":22043867,"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":[],"created_at":"2024-10-13T19:21:48.882Z","updated_at":"2025-05-15T05:07:50.534Z","avatar_url":"https://github.com/zesterer.png","language":"Rust","readme":"# Pollster\n\nPollster is an incredibly minimal async executor for Rust that lets you block a thread until a future completes.\n\n[![Cargo](https://img.shields.io/crates/v/pollster.svg)](\nhttps://crates.io/crates/pollster)\n[![Documentation](https://docs.rs/pollster/badge.svg)](\nhttps://docs.rs/pollster)\n[![License](https://img.shields.io/badge/license-MIT%2FApache--2.0-blue.svg)](\nhttps://github.com/zesterer/pollster)\n[![Actions](https://github.com/zesterer/pollster/actions/workflows/rust.yml/badge.svg)](https://github.com/zesterer/pollster/actions/workflows/rust.yml)\n\n```rust\nuse pollster::FutureExt as _;\n\nlet my_fut = async {};\n\nlet result = my_fut.block_on();\n```\n\nThat's it. That's all it does. Nothing more, nothing less. No need to pull in 50 crates to evaluate a future.\n\n## Why is this useful?\n\nNow that `async` functions are stable, we're increasingly seeing libraries all over the Rust ecosystem expose `async`\nAPIs. This is great for those wanting to build highly concurrent web applications!\n\nHowever, many of us are *not* building highly concurrent web applications, but end up faced with an `async` function\nthat we can't easily call from synchronous code. If you're in this position, then `pollster` is for you: it allows you\nto evaluate a future in-place without spinning up a heavyweight runtime like `tokio` or `async_std`.\n\n## Minimalism\n\nPollster is built with the [UNIX ethos](https://en.wikipedia.org/wiki/Unix_philosophy#Do_One_Thing_and_Do_It_Well) in\nmind: do one thing, and do it well. It has no dependencies, compiles quickly, and is composed of only ~100 lines of\nwell-audited code.\n\n## Behaviour\n\nPollster will synchronously block the thread until a future completes. It will not spin: instead, it will place the\nthread into a waiting state until the future has been polled to completion.\n\n## Compatibility\n\nUnfortunately, `pollster` will not work for *all* futures because some require a specific runtime or reactor. See\n[here](https://rust-lang.github.io/async-book/08_ecosystem/00_chapter.html#determining-ecosystem-compatibility) for more\ninformation about when and where `pollster` may be used. However, if you're already pulling in the required dependencies\nto create such a future in the first place, it's likely that you already have a version of `block_on` in your dependency\ntree that's designed to poll your future, so use that instead.\n\n## Macro\n\nWhen using the `macro` crate feature, an attribute-macro can be used to mark `async fn main()`:\n```rust,ignore\n#[pollster::main]\nasync fn main() {\n    let my_fut = async {};\n\n    my_fut.await;\n}\n```\n\nAdditionally if you have re-exported the crate with a different name then `pollster`, you have to specify it:\n```rust,ignore\n#[pollster::main(crate = renamed_pollster)]\nasync fn main() {\n    let my_fut = async {};\n\n    my_fut.await;\n}\n```\n\nYou can also use `#[pollster::test]` for tests.\n\n## Comparison with `futures::executor::block_on`\n\n`pollster` does approximately the same thing as the `block_on` function from the `futures` crate. If you already have `futures` in your dependency tree, you might as well use it instead. `pollster` is primarily for applications that don't care to pull all of `futures` or another runtime like `tokio` into their dependency tree for the sake of evaluating simple futures.\n\n## Minimum Supported Rust Version (MSRV) Policy\n\nCurrent MSRV: `1.69.0`\n\n`pollster` has a policy of supporting compiler versions that are at least 18 months old. The crate *may* compile with\nolder compilers, but this is not guaranteed.\n","funding_links":["https://github.com/sponsors/zesterer"],"categories":["Rust"],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fzesterer%2Fpollster","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fzesterer%2Fpollster","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fzesterer%2Fpollster/lists"}