callbag-rs
Rust implementation of the callbag spec for reactive/iterable programming.
Basic callbag factories and operators to get started with.
Highlights:
- Supports reactive stream programming
- Supports iterable programming (also!)
- Same operator works for both of the above
- Extensible
Imagine a hybrid between an Observable and an (Async)Iterable, that's what callbags are all about. It's all done with a few simple callbacks, following the callbag spec.
Examples
Reactive programming examples
Pick the first 5 odd numbers from a clock that ticks every second, then start observing them:
use Nursery;
use SegQueue;
use ;
use ;
let = new;
let actual = new;
pipe!;
drop;
block_on;
assert_eq!;
Iterable programming examples
From a range of numbers, pick 5 of them and divide them by 4, then start pulling those one by one:
use SegQueue;
use Arc;
use ;
let actual = new;
pipe!;
assert_eq!;
Ok::
API
The list below shows what's included.
Source factories
Sink factories
Transformation operators
Filtering operators
Combination operators
Utilities
Terminology
- source: a callbag that delivers data
- sink: a callbag that receives data
- puller sink: a sink that actively requests data from the source
- pullable source: a source that delivers data only on demand (on receiving a request)
- listener sink: a sink that passively receives data from the source
- listenable source: source which sends data to the sink without waiting for requests
- operator: a callbag based on another callbag which applies some operation
License
Licensed under either of
- Apache License, Version 2.0, (LICENSE-APACHE or https://www.apache.org/licenses/LICENSE-2.0)
- MIT license (LICENSE-MIT or https://opensource.org/licenses/MIT)
at your option.
Contribution
Unless you explicitly state otherwise, any contribution intentionally submitted for inclusion in the work by you, as defined in the Apache-2.0 license, shall be dual licensed as above, without any additional terms or conditions.
Acknowledgements
Thanks to André Staltz (@staltz) for creating the callbag spec.
This library is a port of https://github.com/staltz/callbag-basics. Some inspiration was taken from https://github.com/f5io/callbag.rs.
Many thanks to the awesome folks on the Rust Users Forum for their help, especially: