1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57
//! `Hey_listen` is a collection of event-dispatchers aiming to suit all needs! //! //! Covering synchronous, parallel, and sync-prioritised dispatching to //! Closures, Enums, Structs, and every other type supporting `trait`-implementation. //! //! View the [`examples`] on how to use each dispatcher. //! //! # Usage //! Add this to your `Cargo.toml`: //! //! ```toml //! [dependencies] //! hey_listen = "0.3.0" //! ``` //! //! # Example //! Here is a quick example on how to use the sync event-dispatcher: //! //! ```rust //! use hey_listen::{ //! RwLock, //! sync::{Listener, Dispatcher, SyncDispatcherRequest}, //! }; //! use std::sync::Arc; //! //! #[derive(Clone, Eq, Hash, PartialEq)] //! enum Event { //! EventType, //! } //! //! struct ListenerStruct {} //! //! impl Listener<Event> for ListenerStruct { //! fn on_event(&mut self, event: &Event) -> Option<SyncDispatcherRequest> { //! println!("I'm listening! :)"); //! //! None //! } //! } //! //! fn main() { //! let listener = Arc::new(RwLock::new(ListenerStruct {})); //! let mut dispatcher: Dispatcher<Event> = Dispatcher::default(); //! //! dispatcher.add_listener(Event::EventType, &listener); //! } //! //! ``` //! [`examples`]: https://github.com/Lakelezz/hey_listen/tree/master/examples #![deny(rust_2018_idioms)] use failure; pub mod rc; pub mod sync; pub use parking_lot::RwLock;