| Crates.io | continue_stream |
| lib.rs | continue_stream |
| version | 0.1.0 |
| created_at | 2025-08-18 03:53:21.876631+00 |
| updated_at | 2025-08-18 03:53:21.876631+00 |
| description | A Swift-style AsyncIterator.Continuation-style channel for Rust |
| homepage | https://sealedabstract.com/code/continue_stream |
| repository | https://github.com/drewcrawford/continue_stream |
| max_upload_size | |
| id | 1799919 |
| size | 118,463 |

A Swift-style AsyncIterator.Continuation-style channel for Rust.
This crate provides a lightweight, single-producer single-consumer (SPSC) channel designed specifically for bridging synchronous and asynchronous code. It's the streaming counterpart to the continue crate, optimized for sending multiple values over time rather than a single result.
futures::Stream for ergonomic async iterationno_std compatible: Works in embedded and WASM environments with allocLike the continue crate:
Clone, or consider more complex solutions if you need multiple producers or consumers.Unlike the continue crate:
None on the receiver.Unlike more complex channel types:
Clone simplifies the problem and unlocks the potential for more efficient implementations.Add this to your Cargo.toml:
[dependencies]
continue_stream = "0.1.0"
For no_std environments (embedded, WASM):
[dependencies]
continue_stream = { version = "0.1.0", default-features = false }
no_std compatible: Works without the standard library, only requires allocstd and no_std environmentsuse continue_stream::continuation;
let (sender, receiver) = continuation::<i32>();
// Send from synchronous code
sender.send(1);
sender.send(2);
sender.send(3);
drop(sender); // Signal completion
// Receive in async code
while let Some(value) = receiver.receive().await {
println!("Received: {}", value);
}
use continue_stream::continuation;
use futures::StreamExt;
let (sender, receiver) = continuation::<String>();
// Send some messages
sender.send("Hello".to_string());
sender.send("World".to_string());
drop(sender);
// Use Stream combinators
let messages: Vec<String> = receiver.collect().await;
assert_eq!(messages, vec!["Hello", "World"]);
use continue_stream::continuation;
use std::thread;
use std::time::Duration;
let (sender, receiver) = continuation::<i32>();
// Spawn a thread that sends values
thread::spawn(move || {
for i in 0..5 {
sender.send(i);
thread::sleep(Duration::from_millis(10));
}
// Sender is dropped here, signaling completion
});
// Receive values asynchronously
let mut count = 0;
while let Some(value) = receiver.receive().await {
assert_eq!(value, count);
count += 1;
}
assert_eq!(count, 5);
use continue_stream::continuation;
let (sender, receiver) = continuation::<i32>();
// Drop the receiver to cancel
drop(receiver);
// Sender can detect cancellation
assert!(sender.is_cancelled());
The crate provides three main types:
continuation<T>() -> (Sender<T>, Receiver<T>)Creates a new continuation channel, returning a sender-receiver pair.
Sender<T>The sending half of a continuation channel. Allows synchronous code to send values to an asynchronous receiver.
send(item: T) - Sends a value through the channel (non-blocking)is_cancelled() -> bool - Checks if the receiver has been droppedReceiver<T>The receiving half of a continuation channel. Provides asynchronous access to values sent through a Sender.
receive() -> ReceiveFuture<T> - Receives a single value from the channelis_cancelled() -> bool - Checks if the sender has been droppedImplements futures::Stream for ergonomic async iteration.
This project is licensed under the MIT or Apache-2.0 license, at your option.