//! Enumeration of all the possible server responses. #![allow(non_camel_case_types)] use std::str::FromStr; macro_rules! make_response { ($($(#[$attr:meta])+ $variant:ident = $value:expr),+) => { /// List of all server responses as defined in /// [RFC 2812](http://tools.ietf.org/html/rfc2812) and /// [Modern docs](https://modern.ircdocs.horse/#numerics) (henceforth referred to as /// Modern). All commands are documented with their expected form from the RFC, and any /// useful, additional information about the response code. #[derive(Clone, Copy, Debug, PartialEq)] #[repr(u16)] pub enum Response { $($(#[$attr])+ $variant = $value),+ } impl Response { /// Generates a Response from a u16. fn from_u16(val: u16) -> Option { match val { $($value => Some(Response::$variant),)+ _ => None } } } } } make_response! { // Expected replies /// `001 Welcome to the Internet Relay Network !@` (Source: RFC2812) RPL_WELCOME = 1, /// `002 Your host is , running version ` (Source: RFC2812) RPL_YOURHOST = 2, /// `003 This server was created ` (Source: RFC2812) RPL_CREATED = 3, /// `004 ` (Source: /// RFC2812) /// /// Various IRCds may choose to include additional arguments to `RPL_MYINFO`, and it's best to /// check for certain what the servers you're targeting do. Typically, there are additional /// parameters at the end for modes that have parameters, and server modes. RPL_MYINFO = 4, /// `005 *((=)) :are supported by this server` (Source: Modern) /// /// [RPL_ISUPPORT](https://modern.ircdocs.horse/#rplisupport-005) replaces RPL_BOUNCE from /// RFC2812, but does so consistently in modern IRCd implementations. RPL_BOUNCE has been moved /// to `010`. RPL_ISUPPORT = 5, /// `010 Try server , port ` (Source: Modern) RPL_BOUNCE = 10, /// Undefined format. (Source: Modern) /// /// RPL_NONE is a dummy numeric. It does not have a defined use nor format. RPL_NONE = 300, /// `302 :*1 *( " " )` (Source: RFC2812) RPL_USERHOST = 302, /// `303 :*1 *( " " )` (Source: RFC2812) RPL_ISON = 303, /// `301 :` (Source: RFC2812) RPL_AWAY = 301, /// `305 :You are no longer marked as being away` (Source: RFC2812) RPL_UNAWAY = 305, /// `306 :You have been marked as being away` (Source: RFC2812) RPL_NOWAWAY = 306, /// `311 * :` (Source: RFC2812) RPL_WHOISUSER = 311, /// `312 :` (Source: RFC2812) RPL_WHOISSERVER = 312, /// `313 :is an IRC operator` (Source: RFC2812) RPL_WHOISOPERATOR = 313, /// `317 :seconds idle` (Source: RFC2812) RPL_WHOISIDLE = 317, /// `318 :End of WHOIS list` (Source: RFC2812) RPL_ENDOFWHOIS = 318, /// `319 :*( ( "@" / "+" ) " " )` (Source: RFC2812) RPL_WHOISCHANNELS = 319, /// `314 * :` (Source: RFC2812) RPL_WHOWASUSER = 314, /// `369 :End of WHOWAS` (Source: RFC2812) RPL_ENDOFWHOWAS = 369, /// Obsolete. Not used. (Source: RFC2812) RPL_LISTSTART = 321, /// `322 <# visible> :` (Source: RFC2812) RPL_LIST = 322, /// `323 :End of LIST (Source: RFC2812) RPL_LISTEND = 323, /// `325 ` (Source: RFC2812) RPL_UNIQOPIS = 325, /// `324 ` (Source: RFC2812) RPL_CHANNELMODEIS = 324, /// `331 :No topic is set` (Source: RFC2812) RPL_NOTOPIC = 331, /// `332 :` (Source: RFC2812) RPL_TOPIC = 332, /// `333 !@ ` (Source: RFC2812) RPL_TOPICWHOTIME = 333, /// `341 ` (Source: RFC2812) RPL_INVITING = 341, /// `342 :Summoning user to IRC` (Source: RFC2812) /// /// According to Modern, this response is rarely implemented. In practice, people simply message /// one another in a channel with their specified username in the message, rather than use the /// `SUMMON` command. RPL_SUMMONING = 342, /// `346 ` (Source: RFC2812) RPL_INVITELIST = 346, /// `347 :End of channel invite list` (Source: RFC2812) /// /// According to Modern, `RPL_ENDOFEXCEPTLIST` (349) is frequently deployed for this same /// purpose and the difference will be noted in channel mode and the statement in the suffix. RPL_ENDOFINVITELIST = 347, /// `348 ` (Source: RFC2812) RPL_EXCEPTLIST = 348, /// `349 :End of channel exception list` (Source: RFC2812) RPL_ENDOFEXCEPTLIST = 349, /// `351 :` (Source: RFC2812/Modern) RPL_VERSION = 351, /// `352 ( "H" / "G" > ["*"] [ ( "@" / "+" ) ] /// : ` (Source: RFC2812) RPL_WHOREPLY = 352, /// `315 :End of WHO list` (Source: RFC2812) RPL_ENDOFWHO = 315, /// `353 ( "=" / "*" / "@" ) :[ "@" / "+" ] *( " " [ "@" / "+" ] )` /// (Source: RFC2812) RPL_NAMREPLY = 353, /// `366 :End of NAMES list` (Source: RFC2812) RPL_ENDOFNAMES = 366, /// `364 : ` (Source: RFC2812) RPL_LINKS = 364, /// `365 :End of LINKS list` (Source: RFC2812) RPL_ENDOFLINKS = 365, /// `367 ` (Source: RFC2812) RPL_BANLIST = 367, /// `368 :End of channel ban list` (Source: RFC2812) RPL_ENDOFBANLIST = 368, /// `371 :` (Source: RFC2812) RPL_INFO = 371, /// `374 :End of INFO list` (Source: RFC2812) RPL_ENDOFINFO = 374, /// `375 :- Message of the day -` (Source: RFC2812) RPL_MOTDSTART = 375, /// `372 :- ` (Source: RFC2812) RPL_MOTD = 372, /// `376 :End of MOTD command` (Source: RFC2812) RPL_ENDOFMOTD = 376, /// `381 :You are now an IRC operator` (Source: RFC2812) RPL_YOUREOPER = 381, /// `382 :Rehashing` (Source: RFC2812) RPL_REHASHING = 382, /// `383 You are service ` (Source: RFC2812) RPL_YOURESERVICE = 383, /// `391 :` (Source: RFC2812) RPL_TIME = 391, /// `392 :UserID Terminal Host` (Source: RFC2812) RPL_USERSSTART = 392, /// `393 : ` (Source: RFC2812) RPL_USERS = 393, /// `394 :End of users` (Source: RFC2812) RPL_ENDOFUSERS = 394, /// `395 :Nobody logged in` (Source: RFC2812) RPL_NOUSERS = 395, /// `396 :is now your displayed host` (Source: InspIRCd) /// /// This response code is sent after a user enables the user mode +x (host masking), and it is /// successfully enabled. The particular format described above is from InspIRCd, but the /// response code should be common amongst servers that support host masks. RPL_HOSTHIDDEN = 396, /// `200 Link V /// ` (Source: RFC2812) RPL_TRACELINK = 200, /// `201 Try. ` (Source: RFC2812) RPL_TRACECONNECTING = 201, /// `202 H.S. ` (Source: RFC2812) RPL_TRACEHANDSHAKE = 202, /// `203 ???? []` (Source: RFC2812) RPL_TRACEUKNOWN = 203, /// `204 Oper ` (Source: RFC2812) RPL_TRACEOPERATOR = 204, /// `205 User ` (Source: RFC2812) RPL_TRACEUSER = 205, /// `206 Serv S C @ V` /// (Source: RFC2812) RPL_TRACESERVER = 206, /// `207 Service ` (Source: RFC2812) RPL_TRACESERVICE = 207, /// `208 0 ` (Source: RFC2812) RPL_TRACENEWTYPE = 208, /// `209 Class ` (Source: RFC2812) RPL_TRACECLASS = 209, /// Unused. (Source: RFC2812) RPL_TRACERECONNECT = 210, /// `261 File ` (Source: RFC2812) RPL_TRACELOG = 261, /// `262 :End of TRACE` (Source: RFC2812) RPL_TRACEEND = 262, /// `211 ///