eventroute 0.1.0

Type safe event dispatching with functional middleware
Documentation
  • Coverage
  • 0%
    0 out of 10 items documented0 out of 9 items with examples
  • Size
  • Source code size: 8.16 kB This is the summed size of all the files inside the crates.io package for this release.
  • Documentation size: 1.5 MB This is the summed size of all files generated by rustdoc for all configured targets
  • Ø build duration
  • this release: 9s Average build duration of successful builds.
  • all releases: 9s Average build duration of successful builds in releases after 2024-10-23.
  • Links
  • Homepage
  • nyxtom/eventroute
    0 0 0
  • crates.io
  • Dependencies
  • Versions
  • Owners
  • nyxtom

eventroute

latest version documentation license

eventroute provides a type safe middleware routing using generics rather than a specific event name or identifier. Middleware can be directly passed into .on while .emit provides a simple mechanism for dispatching to callback middleware.

Examples

pub struct Test {
    foo: i32,
}

pub struct Foo {
    bar: i32,
}

#[test]
fn test_router() {
    let mut router = eventroute::new();
    router.on(|i: i32| {
        println!("{}", i * 10);
    });
    router.on(|(a, b): (i32, i32)| {
        println!("{}", a * b);
    });
    router.on(|test: Test| {
        println!("test {}", test.foo);
    });
    router.on(|foo: Foo| {
        println!("bar {}", foo.bar);
    });

    router.emit(3);
    router.emit((2, 3));
    router.emit(Foo { bar: 232 });
    router.emit(Test { foo: 232 });
}