#signals #emitting #across #channel #station #enums #false

radiowave

A library for emitting signals across the entire program

5 releases (2 stable)

2.0.0 Dec 9, 2023
1.0.0 Oct 21, 2023
0.1.2 Oct 19, 2023
0.1.1 Oct 19, 2023
0.1.0 Oct 19, 2023

#3 in #emitting

49 downloads per month

MIT license

6KB
65 lines

RadioWave

A Rust crate for emitting signals across the entire program.

Examples

use radiowave::*;

enum Channel {
    AppEvents = 0,
}

fn main() {
    let station = RadioStation::new(Channel::AppEvents as usize);

    if station.signal_exists("saycow") == false {
        println!("Hmmmm... let us say moooooo!");

        station.send_signal("saycow", "Mooooo! Says the cow.").unwrap(); // This statement fails if the signal already exists.
    }

    else {
        println!("Cancelling signal!");

        station.cancel_signal_if_exists("saycow");
    }
}

fn moo() {
    let station = RadioStation::new(Channel::AppEvents as usize);

    let what_does_the_cow_say: String = station.wait_for_signal("saycow");

    println!("The cow says: {}", what_does_the_cow_say);
}

No runtime deps