Crates.io | asynk-strim |
lib.rs | asynk-strim |
version | |
source | src |
created_at | 2024-10-07 12:53:15.907558 |
updated_at | 2024-10-09 00:30:38.891894 |
description | Lightweight stream generator library |
homepage | |
repository | https://github.com/aumetra/asynk-strim.git |
max_upload_size | |
id | 1399947 |
Cargo.toml error: | TOML parse error at line 25, column 1 | 25 | autolib = false | ^^^^^^^ unknown field `autolib`, expected one of `name`, `version`, `edition`, `authors`, `description`, `readme`, `license`, `repository`, `homepage`, `documentation`, `build`, `resolver`, `links`, `default-run`, `default_dash_run`, `rust-version`, `rust_dash_version`, `rust_version`, `license-file`, `license_dash_file`, `license_file`, `licenseFile`, `license_capital_file`, `forced-target`, `forced_dash_target`, `autobins`, `autotests`, `autoexamples`, `autobenches`, `publish`, `metadata`, `keywords`, `categories`, `exclude`, `include` |
size | 0 |
Like async-stream
but without macros. Like async-fn-stream
but a little more efficient.
Features:
futures-core
which I don't count since it provides the Stream
definition)no_std
-compatible, zero allocationsThis crate adds a wrapper around the wakers that contains data and pointers needed to yield items.
Crates like embassy
use a similar approach and will therefore clash with us.
If you run into this issue (which will manifest as a runtime panic), you can use the unwrap_waker
function.
This function will wrap a future and remove the waker wrapper.
While you can't use the yielder inside the unwrapped future, stuff like embassy
should work again.
use futures_lite::stream;
use std::pin::pin;
let stream = pin!(asynk_strim::stream_fn(|mut yielder| async move {
yielder.yield_item("hello world!").await;
yielder.yield_item("pretty neato, ain't it?").await;
}));
let mut stream = stream::block_on(stream);
assert_eq!(stream.next(), Some("hello world!"));
assert_eq!(stream.next(), Some("pretty neato, ain't it?"));
assert_eq!(stream.next(), None);
async-stream
In comparison to async-stream
we offer the following advantages:
no_std
supportasync-fn-stream
In comparison to async-stream
we offer the following advantages:
no_std
supportThis crate combines approaches from the following crates:
async-stream
async-fn-stream
async-stream
Licensed under tither the MIT or Apache 2.0 license (at your choosing)