kal-mux

Crates.iokal-mux
lib.rskal-mux
version0.1.0
created_at2026-01-16 10:41:39.364976+00
updated_at2026-01-16 10:41:39.364976+00
descriptionA lightweight stream multiplexer for merging ordered async streams
homepage
repositoryhttps://github.com/0k/kal-mux
max_upload_size
id2048407
size37,808
Valentin Lab (vaab)

documentation

README

kal-mux is a Rust tiny library providing a simple ordering stream multiplexer.

Maturity

This code is around ~100 lines of rust, and has 100% test coverage.

However, it is still considered to be in beta stage currently.

Compatibility

It is small and simple, and has 1 dependency towards futures.

Features

  • support any type of streamed object
  • support of any type of comparison function (allows capturing closure)

Usage

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]);
});

Changelog

See CHANGELOG.md for the full history of changes.

Commit count: 0

cargo fmt