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
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
//! Utility module providing helper types and macros for the I/O event system.
//!
//! This module contains various utility components that support the event system:
//! - Macros for creating subscribers
//! - Type aliases for common result types
//! - Error handling utilities
//! - Iterator implementations for error handling
//!
//! # Examples
//! ```rust
//! use ioevent::prelude::*;
//!
//! // Using the create_subscriber macro
//! #[subscriber]
//! async fn handle_event(state: State<()>, event: MyEvent) -> Result {
//! println!("Event received: {:?}", event);
//! Ok(())
//! }
//!
//! let subscriber = create_subscriber!(handle_event);
//! ```
//!
//! For more examples and detailed usage, see the individual component documentation.
//! - Macros for creating surs
//! - Type aliases for common result types
use AsyncRead;
use mpsc;
use crate::;
/// A macro for creating a subscriber for a given event type.
///
/// This macro generates a subscriber for a specific event type, allowing the system to
/// register and handle events of that type. It simplifies the process of creating
/// subscribers by automatically handling the event type information. event: &MyEvent) -> Result<(), CallSubscribeError> {
///
/// # Arguments
/// * `$func` - The function to create a subscriber for
///
/// # Returns
/// A subscriber for the given event type
///
/// # Examples
/// ```rust
/// use ioevent::prelude::*;
///
/// #[subscriber]
/// async fn handle_user_event(state: &State<()>, event: &UserEvent) -> Result<(), CallSubscribeError> {
/// println!("User event received: {:?}", event);
/// Ok(())
/// }
///
/// let subscriber = create_subscriber!(handle_user_event);
/// ```
/// A macro for creating a subscriber for a given event type.
/// A type alias for the result of a function that returns a CallSubscribeError.
///
/// This type alias simplifies the usage of the CallSubscribeError type, making it
/// easier to handle errors in a more concise manner.
///
/// # Examples
/// ```rust
/// use ioevent::prelude::*;
///
/// async fn process_event(state: &State<()>, event: &EventData) -> Result {
/// // Process the event
/// Ok(())
/// }
/// ```
pub type Result = Result;
/// An iterator over center errors that can occur during event distribution.
///
/// This enum represents errors that can occur in the center ticker:
/// - Left variant: Errors from sending events through channels
/// - Right variant: Errors from receiving events from channels
///
/// # Examples
/// ```rust
/// use ioevent::prelude::*;
///
/// for error in center_error_iter {
/// match error {
/// CenterError::Left(e) => handle_send_error(e),
/// CenterError::Right(e) => handle_recv_error(e),
/// }
/// }
/// ```
/// An error that can occur in the center ticker.
///
/// This enum represents the two types of errors that can occur:
/// - Left variant: Errors from sending events
/// - Right variant: Errors from receiving events
///
/// # Examples
/// ```rust
/// use ioevent::prelude::*;
///
/// match center_error {
/// CenterError::Left(e) => handle_send_error(e),
/// CenterError::Right(e) => handle_recv_error(e),
/// }
/// ```
/// # Returns
/// An error occurred while sending an event
/// A subscriber for the given event type
/// An error occurred while receiving an event
///