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
58
59
60
61
62
63
64
65
66
67
68
69
70
71
//! # Rust Events Crate
//!
//! This crate provides a flexible, modular event system for Rust applications.
//!
//! - **Listener**: Represents a struct that holds a tag (optional), callback, and lifetime (optional) which can be registered to an event.
//! - **EventEmitter**: Manages event registration and emission.
//! - **EventHandler**: Trait defining the event API.
//!
//! By default, the crate uses the `threaded` (multi-threaded, async) implementation.
//! All core types are exported from the `threaded` module.
//!
//! ## Usage Examples
//!
//! **Threaded (default)**
//! ```rust
//! use rs_events::{EventEmitter, EventPayload, EventHandler};
//! use std::sync::Arc;
//!
//! let mut emitter = EventEmitter::<String>::default();
//! emitter.add("event", None, Arc::new(|payload| {
//! println!("Received: {}", payload.as_ref());
//! })).unwrap();
//! emitter.emit("event", Arc::new("Hello World".to_string())).unwrap();
//! ```
//!
//! **no_std/alloc**
//! Build with:
//! ```shell
//! cargo build --no-default-features
//! ```
//!
//! ```rust
//! extern crate alloc;
//! use alloc::sync::Arc;
//! use alloc::string::String;
//! use rs_events::{EventEmitter, EventPayload, EventHandler};
//!
//! let mut emitter = EventEmitter::<String>::default();
//! emitter.add("event", None, Arc::new(|payload| {
//! // Handle event
//! })).unwrap();
//! emitter.emit("event", Arc::new(String::from("Hello no_std!"))).unwrap();
//! ```
pub use crate*;
pub use crate*;
// Base (non-threaded) backend
pub use ;
// Threaded backend
pub use ;