morb 0.1.0

A lightweight in-process publish/subscribe library for Rust
Documentation
  • Coverage
  • 0%
    0 out of 25 items documented0 out of 24 items with examples
  • Size
  • Source code size: 21.49 kB This is the summed size of all the files inside the crates.io package for this release.
  • Documentation size: 1.51 MB This is the summed size of all files generated by rustdoc for all configured targets
  • Ø build duration
  • this release: 36s Average build duration of successful builds.
  • all releases: 33s Average build duration of successful builds in releases after 2024-10-23.
  • Links
  • Homepage
  • HumpbackLab/morb
    1 0 0
  • crates.io
  • Dependencies
  • Versions
  • Owners
  • Ncerzzk

morb

morb is a lightweight in-process publish/subscribe library for Rust. It provides named Topics, a fixed-size ring buffer, and poll-based notifications built on mio and eventfd.

The current implementation targets Linux.

Quick Start

use morb::{create_topic, TopicPoller};
use std::time::Duration;

fn main() -> std::io::Result<()> {
    let topic = create_topic::<u32>("numbers".to_string(), 16)?;
    let publisher = topic.create_publisher();
    let mut subscriber = topic.create_subscriber();

    publisher.publish(42);
    assert!(subscriber.check_update());
    assert_eq!(subscriber.check_update_and_copy(), Some(42));

    let mut poller = TopicPoller::new();
    poller.add_topic(&topic)?;

    publisher.publish(100);
    poller.wait(Some(Duration::from_millis(100)))?;

    for token in poller.iter() {
        if token == topic.token() {
            println!("{} updated", topic.name());
        }
    }

    Ok(())
}

Run tests:

cargo test