| Crates.io | kal-mux |
| lib.rs | kal-mux |
| version | 0.1.0 |
| created_at | 2026-01-16 10:41:39.364976+00 |
| updated_at | 2026-01-16 10:41:39.364976+00 |
| description | A lightweight stream multiplexer for merging ordered async streams |
| homepage | |
| repository | https://github.com/0k/kal-mux |
| max_upload_size | |
| id | 2048407 |
| size | 37,808 |
kal-mux is a Rust tiny library providing a simple ordering stream
multiplexer.
This code is around ~100 lines of rust, and has 100% test coverage.
However, it is still considered to be in beta stage currently.
It is small and simple, and has 1 dependency towards futures.
Given a list of streams outputting ordered content, this mux_by
will produce a unique stream with ordered content coming from all
streams.
Ordering is set by providing a cmp function.
futures::executor::block_on(async {
let s1 = futures::stream::iter([1, 3, 5]);
let s2 = futures::stream::iter([2, 4, 6]);
let merged = kal_mux::mux_by(vec![s1, s2], |a: &i32, b: &i32| a.cmp(b));
let out: Vec<_> = futures::StreamExt::collect(merged).await;
assert_eq!(out, vec![1, 2, 3, 4, 5, 6]);
});
See CHANGELOG.md for the full history of changes.