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
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
#![allow(missing_debug_implementations, missing_copy_implementations)]
/*!
Available event filters.

These can be used with [Dispatcher::subscribe][Subscribe] to get a [Stream] of [Messages] filtered to this event.

See the [table]

[Subscribe]: ../struct.Dispatcher.html#method.subscribe
[Stream]: https://docs.rs/tokio/0.2/tokio/stream/trait.Stream.html
[Messages]: ../messages/index.html
[table]: ../struct.Dispatcher.html#a-table-of-mappings
*/
use super::messages;
use crate::runner::Event;

/// Used to get a [messages::Cap][Cap]
///
/// [Cap]: ../messages/struct.Cap.html
#[non_exhaustive]
pub struct Cap;

impl<'t> Event<'t> for Cap {
    type Parsed = messages::Cap<'t>;
}

/// Used to get a [messages::ClearChat][ClearChat]
///
/// [ClearChat]: ../messages/struct.ClearChat.html
#[non_exhaustive]
pub struct ClearChat;

impl<'t> Event<'t> for ClearChat {
    type Parsed = messages::ClearChat<'t>;
}

/// Used to get a [messages::ClearMsg][ClearMsg]
///
/// [ClearMsg]: ../messages/struct.ClearMsg.html
#[non_exhaustive]
pub struct ClearMsg;

impl<'t> Event<'t> for ClearMsg {
    type Parsed = messages::ClearMsg<'t>;
}

/// Used to get a [messages::GlobalUserState][GlobalUserState]
///
/// [GlobalUserState]: ../messages/struct.GlobalUserState.html
#[non_exhaustive]
pub struct GlobalUserState;

impl<'t> Event<'t> for GlobalUserState {
    type Parsed = messages::GlobalUserState<'t>;
}

/// Used to get a [messages::HostTarget][HostTarget]
///
/// [HostTarget]: ../messages/struct.HostTarget.html
#[non_exhaustive]
pub struct HostTarget;

impl<'t> Event<'t> for HostTarget {
    type Parsed = messages::HostTarget<'t>;
}

/// Used to get a [messages::IrcReady][IrcReady]
///
/// [IrcReady]: ../messages/struct.IrcReady.html
#[non_exhaustive]
pub struct IrcReady;

impl<'t> Event<'t> for IrcReady {
    type Parsed = messages::IrcReady<'t>;
}

/// Used to get a [messages::Join][Join]
///
/// [Join]: ../messages/struct.Join.html
#[non_exhaustive]
pub struct Join;

impl<'t> Event<'t> for Join {
    type Parsed = messages::Join<'t>;
}

/// Used to get a [messages::Mode][Mode]
///
/// [Mode]: ../messages/struct.Mode.html
#[non_exhaustive]
pub struct Mode;

impl<'t> Event<'t> for Mode {
    type Parsed = messages::Mode<'t>;
}

/// Used to get a [messages::Names][Names]
///
/// [Names]: ../messages/struct.Names.html
#[non_exhaustive]
pub struct Names;

impl<'t> Event<'t> for Names {
    type Parsed = messages::Names<'t>;
}

/// Used to get a [messages::Notice][Notice]
///
/// [Notice]: ../messages/struct.Notice.html
#[non_exhaustive]
pub struct Notice;

impl<'t> Event<'t> for Notice {
    type Parsed = messages::Notice<'t>;
}

/// Used to get a [messages::Part][Part]
///
/// [Part]: ../messages/struct.Part.html
#[non_exhaustive]
pub struct Part;

impl<'t> Event<'t> for Part {
    type Parsed = messages::Part<'t>;
}

/// Used to get a [messages::Ping][Ping]
///
/// [Ping]: ../messages/struct.Ping.html
#[non_exhaustive]
pub struct Ping;

impl<'t> Event<'t> for Ping {
    type Parsed = messages::Ping<'t>;
}

/// Used to get a [messages::Pong][Pong]
///
/// [Pong]: ../messages/struct.Pong.html
#[non_exhaustive]
pub struct Pong;

impl<'t> Event<'t> for Pong {
    type Parsed = messages::Pong<'t>;
}

/// Used to get a [messages::Privmsg][Privmsg]
///
/// [Privmsg]: ../messages/struct.Privmsg.html
#[non_exhaustive]
pub struct Privmsg;

impl<'t> Event<'t> for Privmsg {
    type Parsed = messages::Privmsg<'t>;
}

/// Used to get a [messages::Raw][Raw]
///
/// [Raw]: ../messages/type.Raw.html
#[non_exhaustive]
pub struct Raw;

impl<'t> Event<'t> for Raw {
    type Parsed = messages::Raw<'t>;
}

/// Used to get a [messages::Ready][Ready]
///
/// [Ready]: ../messages/struct.Ready.html
#[non_exhaustive]
pub struct Ready;

impl<'t> Event<'t> for Ready {
    type Parsed = messages::Ready<'t>;
}

/// Used to get a [messages::Reconnect][Reconnect]
///
/// [Reconnect]: ../messages/struct.Reconnect.html
#[non_exhaustive]
pub struct Reconnect;

impl<'t> Event<'t> for Reconnect {
    type Parsed = messages::Reconnect;
}

/// Used to get a [messages::RoomState][RoomState]
///
/// [RoomState]: ../messages/struct.RoomState.html
#[non_exhaustive]
pub struct RoomState;

impl<'t> Event<'t> for RoomState {
    type Parsed = messages::RoomState<'t>;
}

/// Used to get a [messages::UserNotice][UserNotice]
///
/// [UserNotice]: ../messages/struct.UserNotice.html
#[non_exhaustive]
pub struct UserNotice;

impl<'t> Event<'t> for UserNotice {
    type Parsed = messages::UserNotice<'t>;
}

/// Used to get a [messages::UserState][UserState]
///
/// [UserState]: ../messages/struct.UserState.html
#[non_exhaustive]
pub struct UserState;

impl<'t> Event<'t> for UserState {
    type Parsed = messages::UserState<'t>;
}

/// Used to get a [messages::AllCommands][AllCommands]
///
/// [AllCommands]: ../messages/enum.AllCommands.html
#[non_exhaustive]
pub struct All;

impl<'t> Event<'t> for All {
    type Parsed = messages::AllCommands<'t>;
}

// TODO generate this with a macro
use crate::Dispatcher;
pub(crate) fn build_event_map(dispatcher: Dispatcher) -> Dispatcher {
    // TODO this acquires the lock N times
    // if we expose the inner map
    // this we can lock once, add all of the events
    // and release the lock
    dispatcher
        .add_event::<Ready>()
        .add_event::<All>()
        .add_event::<Cap>()
        .add_event::<ClearChat>()
        .add_event::<ClearMsg>()
        .add_event::<GlobalUserState>()
        .add_event::<HostTarget>()
        .add_event::<IrcReady>()
        .add_event::<Join>()
        .add_event::<Mode>()
        .add_event::<Names>()
        .add_event::<Notice>()
        .add_event::<Part>()
        .add_event::<Ping>()
        .add_event::<Pong>()
        .add_event::<Privmsg>()
        .add_event::<Raw>()
        .add_event::<Reconnect>()
        .add_event::<RoomState>()
        .add_event::<UserState>()
}