From 3e02df5fabf1ea31aee61d4ec3e19ad85b312405 Mon Sep 17 00:00:00 2001 From: Till Hoeppner Date: Fri, 26 Jun 2015 21:56:46 +0200 Subject: Revert "Start de-cowification" This reverts commit 03968879ce2b5c57f23667dd5c2af3ca2d48d53e. --- src/command.rs | 89 +++++++++--------- src/event.rs | 6 +- src/reply.rs | 280 +++++++++++++++++++++++++++++---------------------------- 3 files changed, 190 insertions(+), 185 deletions(-) (limited to 'src') diff --git a/src/command.rs b/src/command.rs index b07f95c..08d07d5 100644 --- a/src/command.rs +++ b/src/command.rs @@ -6,8 +6,11 @@ use std::iter::Extend; use message::{ Message, MsgType }; +pub type CS<'a> = Cow<'a, str>; + #[derive(Debug, Hash, Clone, PartialEq, Eq)] -pub enum Command { +#[doc(disables)] +pub enum Command<'a> { /// ```text /// 3.1.1 Password message /// @@ -27,7 +30,7 @@ pub enum Command { /// /// PASS secretpasswordhere /// ``` - PASS(String), + PASS(CS<'a>), /// ```text /// 3.1.2 Nick message @@ -54,7 +57,7 @@ pub enum Command { /// ; Server telling that WiZ changed his /// nickname to Kilroy. /// ``` - NICK(String), + NICK(CS<'a>), /// ```text /// 3.1.3 User message @@ -89,7 +92,7 @@ pub enum Command { /// "Ronnie Reagan", and asking to be set /// invisible. /// ``` - USER(String, String, String, String), + USER(CS<'a>, CS<'a>, CS<'a>, CS<'a>), /// ```text /// 3.1.4 Oper message @@ -113,7 +116,7 @@ pub enum Command { /// using a username of "foo" and "bar" /// as the password. /// ``` - OPER(String, String), + OPER(CS<'a>, CS<'a>), /// ```text /// 3.1.5 User mode message @@ -178,7 +181,7 @@ pub enum Command { /// MODE WiZ -o ; WiZ 'deopping' (removing operator /// status). /// ``` - UMODE(String), + UMODE(CS<'a>), /// ```text /// 3.1.6 Service message @@ -214,7 +217,7 @@ pub enum Command { /// service will only be available on /// servers which name matches "*.fr". /// ``` - SERVICE(String, String, String, String, String, String), + SERVICE(CS<'a>, CS<'a>, CS<'a>, CS<'a>, CS<'a>, CS<'a>), /// ```text /// 3.1.7 Quit @@ -236,7 +239,7 @@ pub enum Command { /// :syrk!kalt@millennium.stealth.net QUIT :Gone to have lunch ; User /// syrk has quit IRC to have lunch. /// ``` - QUIT(Option), + QUIT(Option>), /// ```text /// 3.1.8 Squit @@ -272,7 +275,7 @@ pub enum Command { /// "cm22.eng.umd.edu" from the net with /// comment "Server out of control". /// ``` - SQUIT(String, String), + SQUIT(CS<'a>, CS<'a>), /// ```text /// 3.2.1 Join message @@ -335,7 +338,7 @@ pub enum Command { /// :WiZ!jto@tolsun.oulu.fi JOIN #Twilight_zone ; JOIN message from WiZ /// on channel #Twilight_zone /// ``` - JOIN(Vec, Vec), + JOIN(Vec>, Vec>), /// ```text /// 3.2.2 Part message @@ -371,7 +374,7 @@ pub enum Command { /// "#playzone" with the message "I /// lost". /// ``` - PART(Vec, Option), + PART(Vec>, Option>), /// ```text /// 3.2.3 Channel mode message @@ -456,7 +459,7 @@ pub enum Command { /// MODE !12345ircd O ; Command to ask who the channel /// creator for "!12345ircd" is /// ``` - MODE(String, Vec<(String, String)>), + MODE(CS<'a>, Vec<(CS<'a>, CS<'a>)>), /// ```text``` /// 3.2.4 Topic message @@ -491,7 +494,7 @@ pub enum Command { /// TOPIC #test ; Command to check the topic for /// #test. /// ``` - TOPIC(String, Option), + TOPIC(CS<'a>, Option>), /// ```text /// 3.2.5 Names message @@ -528,7 +531,7 @@ pub enum Command { /// NAMES ; Command to list all visible /// channels and users /// ``` - NAMES(Vec, Option), + NAMES(Vec>, Option>), /// ```text /// 3.2.6 List message @@ -557,7 +560,7 @@ pub enum Command { /// LIST #twilight_zone,#42 ; Command to list channels /// #twilight_zone and #42 /// ``` - LIST(Vec, Option), + LIST(Vec>, Option>), /// ```text /// 3.2.7 Invite message @@ -595,7 +598,7 @@ pub enum Command { /// INVITE Wiz #Twilight_Zone ; Command to invite WiZ to /// #Twilight_zone /// ``` - INVITE(String, String), + INVITE(CS<'a>, CS<'a>), /// ```text /// 3.2.8 Kick command @@ -636,7 +639,7 @@ pub enum Command { /// ; KICK message on channel #Finnish /// from WiZ to remove John from channel /// ``` - KICK(Vec, Vec, Option), + KICK(Vec>, Vec>, Option>), /// ```text /// 3.3.1 Private messages @@ -705,7 +708,7 @@ pub enum Command { /// a host which has a name matching /// *.edu. /// ``` - PRIVMSG(String, String), + PRIVMSG(CS<'a>, CS<'a>), /// ```text /// 3.3.2 Notice @@ -728,7 +731,7 @@ pub enum Command { /// /// See PRIVMSG for more details on replies and examples. /// ``` - NOTICE(String, String), + NOTICE(CS<'a>, CS<'a>), /// ```text /// 3.4.1 Motd message @@ -745,7 +748,7 @@ pub enum Command { /// RPL_MOTDSTART RPL_MOTD /// RPL_ENDOFMOTD ERR_NOMOTD /// ``` - MOTD(Option), + MOTD(Option>), /// ```text /// 3.4.2 Lusers message @@ -768,7 +771,7 @@ pub enum Command { /// RPL_LUSERUNKOWN RPL_LUSERCHANNELS /// RPL_LUSERME ERR_NOSUCHSERVER /// ``` - LUSERS(Option<(String, Option)>), + LUSERS(Option<(CS<'a>, Option>)>), /// ```text /// 3.4.3 Version message @@ -791,7 +794,7 @@ pub enum Command { /// VERSION tolsun.oulu.fi ; Command to check the version of /// server "tolsun.oulu.fi". /// ``` - VERSION(Option), + VERSION(Option>), /// ```text /// 3.4.4 Stats message @@ -840,7 +843,7 @@ pub enum Command { /// STATS m ; Command to check the command usage /// for the server you are connected to /// ``` - STATS(Option<(String, Option)>), + STATS(Option<(CS<'a>, Option>)>), /// ```text /// 3.4.5 Links message @@ -870,7 +873,7 @@ pub enum Command { /// *.bu.edu as seen by the first server /// matching *.edu. /// ``` - LINKS(Option<(Option, String)>), + LINKS(Option<(Option>, CS<'a>)>), /// ```text /// 3.4.6 Time message @@ -892,7 +895,7 @@ pub enum Command { /// TIME tolsun.oulu.fi ; check the time on the server /// "tolson.oulu.fi" /// ``` - TIME(Option), + TIME(Option>), /// ```text /// 3.4.7 Connect message @@ -921,7 +924,7 @@ pub enum Command { /// CONNECT tolsun.oulu.fi 6667 ; Command to attempt to connect local /// server to tolsun.oulu.fi on port 6667 /// - CONNECT(String, i16, Option), + CONNECT(CS<'a>, i16, Option>), /// ```text /// 3.4.8 Trace message @@ -981,7 +984,7 @@ pub enum Command { /// TRACE *.oulu.fi ; TRACE to a server matching /// *.oulu.fi /// ``` - TRACE(Option), + TRACE(Option>), /// ```text /// 3.4.9 Admin command @@ -1010,7 +1013,7 @@ pub enum Command { /// ADMIN syrk ; ADMIN request for the server to /// which the user syrk is connected /// ``` - ADMIN(Option), + ADMIN(Option>), /// ```text /// 3.4.10 Info command @@ -1038,7 +1041,7 @@ pub enum Command { /// INFO Angel ; request info from the server that /// Angel is connected to. /// ``` - INFO(Option), + INFO(Option>), /// ```text /// 3.5.1 Servlist message @@ -1055,7 +1058,7 @@ pub enum Command { /// /// RPL_SERVLIST RPL_SERVLISTEND /// ``` - SERVLIST(Option<(String, Option)>), + SERVLIST(Option<(CS<'a>, Option>)>), /// ```text /// 3.5.2 Squery @@ -1079,7 +1082,7 @@ pub enum Command { /// ; Message to the service with name /// dict@irc.fr. /// ``` - SQUERY(String, String), + SQUERY(CS<'a>, CS<'a>), /// ```text /// 3.6.1 Who query @@ -1115,7 +1118,7 @@ pub enum Command { /// match against "jto*" if they are an /// operator. /// ``` - WHO(Option, bool), + WHO(Option>, bool), /// ```text /// 3.6.2 Whois query @@ -1155,7 +1158,7 @@ pub enum Command { /// WHOIS eff.org trillian ; ask server eff.org for user /// information about trillian /// ``` - WHOIS(Option, Vec), + WHOIS(Option>, Vec>), /// ```text /// 3.6.3 Whowas @@ -1194,7 +1197,7 @@ pub enum Command { /// "Trillian" from the first server /// found to match "*.edu". /// ``` - WHOWAS(Vec, Option<(String, Option)>), + WHOWAS(Vec>, Option<(CS<'a>, Option>)>), /// ```text /// 3.7.1 Kill message @@ -1249,7 +1252,7 @@ pub enum Command { /// recommendation, it is also widely recognized that not even operators /// should be allowed to kill users on remote servers. /// ``` - KILL(String, String), + KILL(CS<'a>, CS<'a>), /// ```text /// 3.7.2 Ping message @@ -1285,7 +1288,7 @@ pub enum Command { /// PING :irc.funet.fi ; Ping message sent by server /// "irc.funet.fi" /// ``` - PING(String, Option), + PING(CS<'a>, Option>), /// ```text /// 3.7.3 Pong message @@ -1307,7 +1310,7 @@ pub enum Command { /// PONG csd.bu.edu tolsun.oulu.fi ; PONG message from csd.bu.edu to /// tolsun.oulu.fi /// ``` - PONG(String, Option), + PONG(CS<'a>, Option>), /// ```text /// 3.7.4 Error @@ -1346,7 +1349,7 @@ pub enum Command { /// ; Same ERROR message as above but /// sent to user WiZ on the other server. /// ``` - ERROR(String), + ERROR(CS<'a>), /// ```text /// 4.1 Away @@ -1378,7 +1381,7 @@ pub enum Command { /// AWAY :Gone to lunch. Back in 5 ; Command to set away message to /// "Gone to lunch. Back in 5". /// ``` - AWAY(Option), + AWAY(Option>), /// ```text /// 4.2 Rehash message @@ -1485,7 +1488,7 @@ pub enum Command { /// server named "tolsun.oulu.fi" is /// running. /// ``` - SUMMON(String, Option<(String, Option)>), + SUMMON(CS<'a>, Option<(CS<'a>, Option>)>), /// ```text /// 4.6 Users @@ -1519,7 +1522,7 @@ pub enum Command { /// USERS eff.org ; request a list of users logged in /// on server eff.org /// ``` - USERS(Option), + USERS(Option>), /// ```text /// 4.7 Operwall message @@ -1548,7 +1551,7 @@ pub enum Command { /// CONNECT message it received from /// Joshua and acted upon. /// ``` - WALLOPS(String), + WALLOPS(CS<'a>), /// ```text /// 4.8 Userhost message @@ -1573,7 +1576,7 @@ pub enum Command { /// :ircd.stealth.net 302 yournick :syrk=+syrk@millennium.stealth.net /// ; Reply for user syrk /// ``` - USERHOST(Vec), + USERHOST(Vec>), } /*impl<'a> Clone for Command<'a> { diff --git a/src/event.rs b/src/event.rs index 8a7e3b7..488ac04 100644 --- a/src/event.rs +++ b/src/event.rs @@ -4,9 +4,9 @@ use command; use reply; #[derive(Debug, Clone, PartialEq)] -pub enum Event { - Command(command::Command), - Reply(reply::Reply), +pub enum Event<'a> { + Command(command::Command<'a>), + Reply(reply::Reply<'a>), Connected, Disconnected } diff --git a/src/reply.rs b/src/reply.rs index cb00806..f7c09e6 100644 --- a/src/reply.rs +++ b/src/reply.rs @@ -5,21 +5,23 @@ use std::borrow::Cow::*; use ::{ Result, IrscError }; use ::message::{ MsgType, Message }; +pub type CS<'a> = Cow<'a, str>; + #[allow(non_camel_case_types)] #[derive(Debug, Hash, Clone, PartialEq, Eq)] -pub enum Reply { +pub enum Reply<'a> { /// 001 RPL_WELCOME /// "Welcome to the Internet Relay Network /// !@" - RPL_WELCOME(String), + RPL_WELCOME(CS<'a>), /// 002 RPL_YOURHOST /// "Your host is , running version " - RPL_YOURHOST(String), + RPL_YOURHOST(CS<'a>), /// 003 RPL_CREATED /// "This server was created " - RPL_CREATED(String), + RPL_CREATED(CS<'a>), /// 004 RPL_MYINFO /// " @@ -28,7 +30,7 @@ pub enum Reply { /// - The server sends Replies 001 to 004 to a user upon /// successful registration. /// - RPL_MYINFO(String), + RPL_MYINFO(CS<'a>), /// 005 RPL_BOUNCE /// "Try server , port " @@ -37,7 +39,7 @@ pub enum Reply { /// server. This is often used when the connection is /// refused because the server is already full. /// - RPL_BOUNCE(String), + RPL_BOUNCE(CS<'a>), /// 302 RPL_USERHOST /// ":*1 *( " " )" @@ -53,7 +55,7 @@ pub enum Reply { /// whether the client has set an AWAY message or not /// respectively. /// - RPL_USERHOST(String), + RPL_USERHOST(CS<'a>), /// 303 RPL_ISON /// ":*1 *( " " )" @@ -61,15 +63,15 @@ pub enum Reply { /// - Reply format used by ISON to list replies to the /// query list. /// - RPL_ISON(String), + RPL_ISON(CS<'a>), /// 301 RPL_AWAY /// " :" - RPL_AWAY(String), + RPL_AWAY(CS<'a>), /// 305 RPL_UNAWAY /// ":You are no longer marked as being away" - RPL_UNAWAY(String), + RPL_UNAWAY(CS<'a>), /// 306 RPL_NOWAWAY /// ":You have been marked as being away" @@ -81,27 +83,27 @@ pub enum Reply { /// Replies RPL_UNAWAY and RPL_NOWAWAY are sent when the /// client removes and sets an AWAY message. /// - RPL_NOWAWAY(String), + RPL_NOWAWAY(CS<'a>), /// 311 RPL_WHOISUSER /// " * :" - RPL_WHOISUSER(String), + RPL_WHOISUSER(CS<'a>), /// 312 RPL_WHOISSERVER /// " :" - RPL_WHOISSERVER(String), + RPL_WHOISSERVER(CS<'a>), /// 313 RPL_WHOISOPERATOR /// " :is an IRC operator" - RPL_WHOISOPERATOR(String), + RPL_WHOISOPERATOR(CS<'a>), /// 317 RPL_WHOISIDLE /// " :seconds idle" - RPL_WHOISIDLE(String), + RPL_WHOISIDLE(CS<'a>), /// 318 RPL_ENDOFWHOIS /// " :End of WHOIS list" - RPL_ENDOFWHOIS(String), + RPL_ENDOFWHOIS(CS<'a>), /// 319 RPL_WHOISCHANNELS /// " :*( ( "@" / "+" ) " " )" @@ -121,11 +123,11 @@ pub enum Reply { /// channel. The RPL_ENDOFWHOIS reply is used to mark /// the end of processing a WHOIS message. /// - RPL_WHOISCHANNELS(String), + RPL_WHOISCHANNELS(CS<'a>), /// 314 RPL_WHOWASUSER /// " * :" - RPL_WHOWASUSER(String), + RPL_WHOWASUSER(CS<'a>), /// 369 RPL_ENDOFWHOWAS /// " :End of WHOWAS" @@ -137,7 +139,7 @@ pub enum Reply { /// be RPL_ENDOFWHOWAS (even if there was only one reply /// and it was an error). /// - RPL_ENDOFWHOWAS(String), + RPL_ENDOFWHOWAS(CS<'a>), /// 321 RPL_LISTSTART /// Obsolete. Not used. @@ -146,7 +148,7 @@ pub enum Reply { /// 322 RPL_LIST /// " <# visible> :" - RPL_LIST(String), + RPL_LIST(CS<'a>), /// 323 RPL_LISTEND /// ":End of LIST" @@ -156,21 +158,21 @@ pub enum Reply { /// command. If there are no channels available to return, /// only the end reply MUST be sent. /// - RPL_LISTEND(String), + RPL_LISTEND(CS<'a>), /// 325 RPL_UNIQOPIS /// " " /// - RPL_UNIQOPIS(String), + RPL_UNIQOPIS(CS<'a>), /// 324 RPL_CHANNELMODEIS /// " " /// - RPL_CHANNELMODEIS(String), + RPL_CHANNELMODEIS(CS<'a>), /// 331 RPL_NOTOPIC /// " :No topic is set" - RPL_NOTOPIC(String), + RPL_NOTOPIC(CS<'a>), /// 332 RPL_TOPIC /// " :" @@ -180,7 +182,7 @@ pub enum Reply { /// the topic is set, RPL_TOPIC is sent back else /// RPL_NOTOPIC. /// - RPL_TOPIC(String), + RPL_TOPIC(CS<'a>), /// 341 RPL_INVITING /// " " @@ -189,7 +191,7 @@ pub enum Reply { /// attempted INVITE message was successful and is /// being passed onto the end client. /// - RPL_INVITING(String), + RPL_INVITING(CS<'a>), /// 342 RPL_SUMMONING /// " :Summoning user to IRC" @@ -197,11 +199,11 @@ pub enum Reply { /// - Returned by a server answering a SUMMON message to /// indicate that it is summoning that user. /// - RPL_SUMMONING(String), + RPL_SUMMONING(CS<'a>), /// 346 RPL_INVITELIST /// " " - RPL_INVITELIST(String), + RPL_INVITELIST(CS<'a>), /// 347 RPL_ENDOFINVITELIST /// " :End of channel invite list" @@ -213,11 +215,11 @@ pub enum Reply { /// After the masks have been listed (or if none present) a /// RPL_ENDOFINVITELIST MUST be sent. /// - RPL_ENDOFINVITELIST(String), + RPL_ENDOFINVITELIST(CS<'a>), /// 348 RPL_EXCEPTLIST /// " " - RPL_EXCEPTLIST(String), + RPL_EXCEPTLIST(CS<'a>), /// 349 RPL_ENDOFEXCEPTLIST /// " :End of channel exception list" @@ -229,7 +231,7 @@ pub enum Reply { /// After the masks have been listed (or if none present) /// a RPL_ENDOFEXCEPTLIST MUST be sent. /// - RPL_ENDOFEXCEPTLIST(String), + RPL_ENDOFEXCEPTLIST(CS<'a>), /// 351 RPL_VERSION /// ". :" @@ -243,14 +245,14 @@ pub enum Reply { /// The "comments" field may contain any comments about /// the version or further version details. /// - RPL_VERSION(String), + RPL_VERSION(CS<'a>), /// 352 RPL_WHOREPLY /// " /// ( "H" / "G" > ["*"] [ ( "@" / "+" ) ] /// : " /// - RPL_WHOREPLY(String), + RPL_WHOREPLY(CS<'a>), /// 315 RPL_ENDOFWHO /// " :End of WHO list" @@ -263,7 +265,7 @@ pub enum Reply { /// after processing each list item with being /// the item. /// - RPL_ENDOFWHO(String), + RPL_ENDOFWHO(CS<'a>), /// 353 RPL_NAMREPLY /// "( "=" / "*" / "@" ) @@ -271,7 +273,7 @@ pub enum Reply { /// - "@" is used for secret channels, "*" for private /// channels, and "=" for others (public channels). /// - RPL_NAMREPLY(String), + RPL_NAMREPLY(CS<'a>), /// 366 RPL_ENDOFNAMES /// " :End of NAMES list" @@ -286,11 +288,11 @@ pub enum Reply { /// RPL_NAMEREPLY messages with a RPL_ENDOFNAMES to mark /// the end. /// - RPL_ENDOFNAMES(String), + RPL_ENDOFNAMES(CS<'a>), /// 364 RPL_LINKS /// " : " - RPL_LINKS(String), + RPL_LINKS(CS<'a>), /// 365 RPL_ENDOFLINKS /// " :End of LINKS list" @@ -299,11 +301,11 @@ pub enum Reply { /// replies back using the RPL_LINKS numeric and mark the /// end of the list using an RPL_ENDOFLINKS reply. /// - RPL_ENDOFLINKS(String), + RPL_ENDOFLINKS(CS<'a>), /// 367 RPL_BANLIST /// " " - RPL_BANLIST(String), + RPL_BANLIST(CS<'a>), /// 368 RPL_ENDOFBANLIST /// " :End of channel ban list" @@ -315,11 +317,11 @@ pub enum Reply { /// banmasks have been listed (or if none present) a /// RPL_ENDOFBANLIST MUST be sent. /// - RPL_ENDOFBANLIST(String), + RPL_ENDOFBANLIST(CS<'a>), /// 371 RPL_INFO /// ":" - RPL_INFO(String), + RPL_INFO(CS<'a>), /// 374 RPL_ENDOFINFO /// ":End of INFO list" @@ -329,15 +331,15 @@ pub enum Reply { /// with a RPL_ENDOFINFO reply to indicate the end of the /// replies. /// - RPL_ENDOFINFO(String), + RPL_ENDOFINFO(CS<'a>), /// 375 RPL_MOTDSTART /// ":- Message of the day - " - RPL_MOTDSTART(String), + RPL_MOTDSTART(CS<'a>), /// 372 RPL_MOTD /// ":- " - RPL_MOTD(String), + RPL_MOTD(CS<'a>), /// 376 RPL_ENDOFMOTD /// ":End of MOTD command" @@ -349,7 +351,7 @@ pub enum Reply { /// by a RPL_MOTDSTART (before the RPL_MOTDs) and an /// RPL_ENDOFMOTD (after). /// - RPL_ENDOFMOTD(String), + RPL_ENDOFMOTD(CS<'a>), /// 381 RPL_YOUREOPER /// ":You are now an IRC operator" @@ -358,7 +360,7 @@ pub enum Reply { /// just successfully issued an OPER message and gained /// operator status. /// - RPL_YOUREOPER(String), + RPL_YOUREOPER(CS<'a>), /// 382 RPL_REHASHING /// " :Rehashing" @@ -367,7 +369,7 @@ pub enum Reply { /// a REHASH message, an RPL_REHASHING is sent back to /// the operator. /// - RPL_REHASHING(String), + RPL_REHASHING(CS<'a>), /// 383 RPL_YOURESERVICE /// "You are service " @@ -375,7 +377,7 @@ pub enum Reply { /// - Sent by the server to a service upon successful /// registration. /// - RPL_YOURESERVICE(String), + RPL_YOURESERVICE(CS<'a>), /// 391 RPL_TIME /// " :" @@ -386,19 +388,19 @@ pub enum Reply { /// time there. There is no further requirement for the /// time string. /// - RPL_TIME(String), + RPL_TIME(CS<'a>), /// 392 RPL_USERSSTART /// ":UserID Terminal Host" - RPL_USERSSTART(String), + RPL_USERSSTART(CS<'a>), /// 393 RPL_USERS /// ": " - RPL_USERS(String), + RPL_USERS(CS<'a>), /// 394 RPL_ENDOFUSERS /// ":End of users" - RPL_ENDOFUSERS(String), + RPL_ENDOFUSERS(CS<'a>), /// 395 RPL_NOUSERS /// ":Nobody logged in" @@ -410,59 +412,59 @@ pub enum Reply { /// or a single RPL_NOUSER. Following this is /// RPL_ENDOFUSERS. /// - RPL_NOUSERS(String), + RPL_NOUSERS(CS<'a>), /// 200 RPL_TRACELINK /// "Link /// V /// /// " - RPL_TRACELINK(String), + RPL_TRACELINK(CS<'a>), /// 201 RPL_TRACECONNECTING /// "Try. " - RPL_TRACECONNECTING(String), + RPL_TRACECONNECTING(CS<'a>), /// 202 RPL_TRACEHANDSHAKE /// "H.S. " - RPL_TRACEHANDSHAKE(String), + RPL_TRACEHANDSHAKE(CS<'a>), /// 203 RPL_TRACEUNKNOWN /// "???? []" - RPL_TRACEUNKNOWN(String), + RPL_TRACEUNKNOWN(CS<'a>), /// 204 RPL_TRACEOPERATOR /// "Oper " - RPL_TRACEOPERATOR(String), + RPL_TRACEOPERATOR(CS<'a>), /// 205 RPL_TRACEUSER /// "User " - RPL_TRACEUSER(String), + RPL_TRACEUSER(CS<'a>), /// 206 RPL_TRACESERVER /// "Serv S C /// @ V" - RPL_TRACESERVER(String), + RPL_TRACESERVER(CS<'a>), /// 207 RPL_TRACESERVICE /// "Service " - RPL_TRACESERVICE(String), + RPL_TRACESERVICE(CS<'a>), /// 208 RPL_TRACENEWTYPE /// " 0 " - RPL_TRACENEWTYPE(String), + RPL_TRACENEWTYPE(CS<'a>), /// 209 RPL_TRACECLASS /// "Class " - RPL_TRACECLASS(String), + RPL_TRACECLASS(CS<'a>), /// 210 RPL_TRACERECONNECT /// Unused. - RPL_TRACERECONNECT(String), + RPL_TRACERECONNECT(CS<'a>), /// 261 RPL_TRACELOG /// "File " - RPL_TRACELOG(String), + RPL_TRACELOG(CS<'a>), /// 262 RPL_TRACEEND /// " :End of TRACE" @@ -489,7 +491,7 @@ pub enum Reply { /// being displayed anyway. /// RPL_TRACEEND is sent to indicate the end of the list. /// - RPL_TRACEEND(String), + RPL_TRACEEND(CS<'a>), /// 211 RPL_STATSLINKINFO /// " @@ -507,26 +509,26 @@ pub enum Reply { /// open> indicates how long ago the connection was /// opened, in seconds. /// - RPL_STATSLINKINFO(String), + RPL_STATSLINKINFO(CS<'a>), /// 212 RPL_STATSCOMMANDS /// " " /// /// - reports statistics on commands usage. /// - RPL_STATSCOMMANDS(String), + RPL_STATSCOMMANDS(CS<'a>), /// 219 RPL_ENDOFSTATS /// " :End of STATS report" /// - RPL_ENDOFSTATS(String), + RPL_ENDOFSTATS(CS<'a>), /// 242 RPL_STATSUPTIME /// ":Server Up %d days %d:%02d:%02d" /// /// - reports the server uptime. /// - RPL_STATSUPTIME(String), + RPL_STATSUPTIME(CS<'a>), /// 243 RPL_STATSOLINE /// "O * " @@ -534,7 +536,7 @@ pub enum Reply { /// - reports the allowed hosts from where user may become IRC /// operators. /// - RPL_STATSOLINE(String), + RPL_STATSOLINE(CS<'a>), /// 221 RPL_UMODEIS /// "" @@ -542,12 +544,12 @@ pub enum Reply { /// - To answer a query about a client's own mode, /// RPL_UMODEIS is sent back. /// - RPL_UMODEIS(String), + RPL_UMODEIS(CS<'a>), /// 234 RPL_SERVLIST /// " " /// - RPL_SERVLIST(String), + RPL_SERVLIST(CS<'a>), /// 235 RPL_SERVLISTEND /// " :End of service listing" @@ -559,24 +561,24 @@ pub enum Reply { /// services have been listed (or if none present) a /// RPL_SERVLISTEND MUST be sent. /// - RPL_SERVLISTEND(String), + RPL_SERVLISTEND(CS<'a>), /// 251 RPL_LUSERCLIENT /// ":There are users and /// services on servers" - RPL_LUSERCLIENT(String), + RPL_LUSERCLIENT(CS<'a>), /// 252 RPL_LUSEROP /// " :operator(s) online" - RPL_LUSEROP(String), + RPL_LUSEROP(CS<'a>), /// 253 RPL_LUSERUNKNOWN /// " :unknown connection(s)" - RPL_LUSERUNKNOWN(String), + RPL_LUSERUNKNOWN(CS<'a>), /// 254 RPL_LUSERCHANNELS /// " :channels formed" - RPL_LUSERCHANNELS(String), + RPL_LUSERCHANNELS(CS<'a>), /// 255 RPL_LUSERME /// ":I have clients and @@ -591,19 +593,19 @@ pub enum Reply { /// replies are only sent back if a non-zero count /// is found for them. /// - RPL_LUSERME(String), + RPL_LUSERME(CS<'a>), /// 256 RPL_ADMINME /// " :Administrative info" - RPL_ADMINME(String), + RPL_ADMINME(CS<'a>), /// 257 RPL_ADMINLOC1 /// ":" - RPL_ADMINLOC1(String), + RPL_ADMINLOC1(CS<'a>), /// 258 RPL_ADMINLOC2 /// ":" - RPL_ADMINLOC2(String), + RPL_ADMINLOC2(CS<'a>), /// 259 RPL_ADMINEMAIL /// ":" @@ -620,7 +622,7 @@ pub enum Reply { /// server (an email address here is REQUIRED) /// in RPL_ADMINEMAIL. /// - RPL_ADMINEMAIL(String), + RPL_ADMINEMAIL(CS<'a>), /// 263 RPL_TRYAGAIN /// " :Please wait a while and try again." @@ -629,7 +631,7 @@ pub enum Reply { /// it MUST use the reply RPL_TRYAGAIN to inform the /// originating client. /// - RPL_TRYAGAIN(String), + RPL_TRYAGAIN(CS<'a>), /// 401 ERR_NOSUCHNICK /// " :No such nick/channel" @@ -637,7 +639,7 @@ pub enum Reply { /// - Used to indicate the nickname parameter supplied to a /// command is currently unused. /// - ERR_NOSUCHNICK(String), + ERR_NOSUCHNICK(CS<'a>), /// 402 ERR_NOSUCHSERVER /// " :No such server" @@ -645,14 +647,14 @@ pub enum Reply { /// - Used to indicate the server name given currently /// does not exist. /// - ERR_NOSUCHSERVER(String), + ERR_NOSUCHSERVER(CS<'a>), /// 403 ERR_NOSUCHCHANNEL /// " :No such channel" /// /// - Used to indicate the given channel name is invalid. /// - ERR_NOSUCHCHANNEL(String), + ERR_NOSUCHCHANNEL(CS<'a>), /// 404 ERR_CANNOTSENDTOCHAN /// " :Cannot send to channel" @@ -663,7 +665,7 @@ pub enum Reply { /// banned and is trying to send a PRIVMSG message to /// that channel. /// - ERR_CANNOTSENDTOCHAN(String), + ERR_CANNOTSENDTOCHAN(CS<'a>), /// 405 ERR_TOOMANYCHANNELS /// " :You have joined too many channels" @@ -672,7 +674,7 @@ pub enum Reply { /// number of allowed channels and they try to join /// another channel. /// - ERR_TOOMANYCHANNELS(String), + ERR_TOOMANYCHANNELS(CS<'a>), /// 406 ERR_WASNOSUCHNICK /// " :There was no such nickname" @@ -680,7 +682,7 @@ pub enum Reply { /// - Returned by WHOWAS to indicate there is no history /// information for that nickname. /// - ERR_WASNOSUCHNICK(String), + ERR_WASNOSUCHNICK(CS<'a>), /// 407 ERR_TOOMANYTARGETS /// " : recipients. " @@ -696,7 +698,7 @@ pub enum Reply { /// channel using the shortname when there are more than one /// such channel. /// - ERR_TOOMANYTARGETS(String), + ERR_TOOMANYTARGETS(CS<'a>), /// 408 ERR_NOSUCHSERVICE /// " :No such service" @@ -704,30 +706,30 @@ pub enum Reply { /// - Returned to a client which is attempting to send a SQUERY /// to a service which does not exist. /// - ERR_NOSUCHSERVICE(String), + ERR_NOSUCHSERVICE(CS<'a>), /// 409 ERR_NOORIGIN /// ":No origin specified" /// /// - PING or PONG message missing the originator parameter. /// - ERR_NOORIGIN(String), + ERR_NOORIGIN(CS<'a>), /// 411 ERR_NORECIPIENT /// ":No recipient given ()" - ERR_NORECIPIENT(String), + ERR_NORECIPIENT(CS<'a>), /// 412 ERR_NOTEXTTOSEND /// ":No text to send" - ERR_NOTEXTTOSEND(String), + ERR_NOTEXTTOSEND(CS<'a>), /// 413 ERR_NOTOPLEVEL /// " :No toplevel domain specified" - ERR_NOTOPLEVEL(String), + ERR_NOTOPLEVEL(CS<'a>), /// 414 ERR_WILDTOPLEVEL /// " :Wildcard in toplevel domain" - ERR_WILDTOPLEVEL(String), + ERR_WILDTOPLEVEL(CS<'a>), /// 415 ERR_BADMASK /// " :Bad Server/host mask" @@ -738,7 +740,7 @@ pub enum Reply { /// are returned when an invalid use of /// "PRIVMSG $" or "PRIVMSG #" is attempted. /// - ERR_BADMASK(String), + ERR_BADMASK(CS<'a>), /// 421 ERR_UNKNOWNCOMMAND /// " :Unknown command" @@ -746,14 +748,14 @@ pub enum Reply { /// - Returned to a registered client to indicate that the /// command sent is unknown by the server. /// - ERR_UNKNOWNCOMMAND(String), + ERR_UNKNOWNCOMMAND(CS<'a>), /// 422 ERR_NOMOTD /// ":MOTD File is missing" /// /// - Server's MOTD file could not be opened by the server. /// - ERR_NOMOTD(String), + ERR_NOMOTD(CS<'a>), /// 423 ERR_NOADMININFO /// " :No administrative info available" @@ -762,7 +764,7 @@ pub enum Reply { /// when there is an error in finding the appropriate /// information. /// - ERR_NOADMININFO(String), + ERR_NOADMININFO(CS<'a>), /// 424 ERR_FILEERROR /// ":File error doing on " @@ -770,7 +772,7 @@ pub enum Reply { /// - Generic error message used to report a failed file /// operation during the processing of a message. /// - ERR_FILEERROR(String), + ERR_FILEERROR(CS<'a>), /// 431 ERR_NONICKNAMEGIVEN /// ":No nickname given" @@ -778,7 +780,7 @@ pub enum Reply { /// - Returned when a nickname parameter expected for a /// command and isn't found. /// - ERR_NONICKNAMEGIVEN(String), + ERR_NONICKNAMEGIVEN(CS<'a>), /// 432 ERR_ERRONEUSNICKNAME /// " :Erroneous nickname" @@ -787,7 +789,7 @@ pub enum Reply { /// characters which do not fall in the defined set. See /// section 2.3.1 for details on valid nicknames. /// - ERR_ERRONEUSNICKNAME(String), + ERR_ERRONEUSNICKNAME(CS<'a>), /// 433 ERR_NICKNAMEINUSE /// " :Nickname is already in use" @@ -796,7 +798,7 @@ pub enum Reply { /// in an attempt to change to a currently existing /// nickname. /// - ERR_NICKNAMEINUSE(String), + ERR_NICKNAMEINUSE(CS<'a>), /// 436 ERR_NICKCOLLISION /// " :Nickname collision KILL from @" @@ -805,7 +807,7 @@ pub enum Reply { /// nickname collision (registered of a NICK that /// already exists by another server). /// - ERR_NICKCOLLISION(String), + ERR_NICKCOLLISION(CS<'a>), /// 437 ERR_UNAVAILRESOURCE /// " :Nick/channel is temporarily unavailable" @@ -817,7 +819,7 @@ pub enum Reply { /// when the desired nickname is blocked by the nick delay /// mechanism. /// - ERR_UNAVAILRESOURCE(String), + ERR_UNAVAILRESOURCE(CS<'a>), /// 441 ERR_USERNOTINCHANNEL /// " :They aren't on that channel" @@ -825,7 +827,7 @@ pub enum Reply { /// - Returned by the server to indicate that the target /// user of the command is not on the given channel. /// - ERR_USERNOTINCHANNEL(String), + ERR_USERNOTINCHANNEL(CS<'a>), /// 442 ERR_NOTONCHANNEL /// " :You're not on that channel" @@ -834,7 +836,7 @@ pub enum Reply { /// perform a channel affecting command for which the /// client isn't a member. /// - ERR_NOTONCHANNEL(String), + ERR_NOTONCHANNEL(CS<'a>), /// 443 ERR_USERONCHANNEL /// " :is already on channel" @@ -842,7 +844,7 @@ pub enum Reply { /// - Returned when a client tries to invite a user to a /// channel they are already on. /// - ERR_USERONCHANNEL(String), + ERR_USERONCHANNEL(CS<'a>), /// 444 ERR_NOLOGIN /// " :User not logged in" @@ -851,7 +853,7 @@ pub enum Reply { /// user was unable to be performed since they were not /// logged in. /// - ERR_NOLOGIN(String), + ERR_NOLOGIN(CS<'a>), /// 445 ERR_SUMMONDISABLED /// ":SUMMON has been disabled" @@ -859,7 +861,7 @@ pub enum Reply { /// - Returned as a response to the SUMMON command. MUST be /// returned by any server which doesn't implement it. /// - ERR_SUMMONDISABLED(String), + ERR_SUMMONDISABLED(CS<'a>), /// 446 ERR_USERSDISABLED /// ":USERS has been disabled" @@ -867,7 +869,7 @@ pub enum Reply { /// - Returned as a response to the USERS command. MUST be /// returned by any server which does not implement it. /// - ERR_USERSDISABLED(String), + ERR_USERSDISABLED(CS<'a>), /// 451 ERR_NOTREGISTERED /// ":You have not registered" @@ -876,7 +878,7 @@ pub enum Reply { /// MUST be registered before the server will allow it /// to be parsed in detail. /// - ERR_NOTREGISTERED(String), + ERR_NOTREGISTERED(CS<'a>), /// 461 ERR_NEEDMOREPARAMS /// " :Not enough parameters" @@ -885,7 +887,7 @@ pub enum Reply { /// indicate to the client that it didn't supply enough /// parameters. /// - ERR_NEEDMOREPARAMS(String), + ERR_NEEDMOREPARAMS(CS<'a>), /// 462 ERR_ALREADYREGISTRED /// ":Unauthorized command (already registered)" @@ -894,7 +896,7 @@ pub enum Reply { /// change part of the registered details (such as /// password or user details from second USER message). /// - ERR_ALREADYREGISTRED(String), + ERR_ALREADYREGISTRED(CS<'a>), /// 463 ERR_NOPERMFORHOST /// ":Your host isn't among the privileged" @@ -904,7 +906,7 @@ pub enum Reply { /// connections from the host the attempted connection /// is tried. /// - ERR_NOPERMFORHOST(String), + ERR_NOPERMFORHOST(CS<'a>), /// 464 ERR_PASSWDMISMATCH /// ":Password incorrect" @@ -913,7 +915,7 @@ pub enum Reply { /// a connection for which a password was required and /// was either not given or incorrect. /// - ERR_PASSWDMISMATCH(String), + ERR_PASSWDMISMATCH(CS<'a>), /// 465 ERR_YOUREBANNEDCREEP /// ":You are banned from this server" @@ -922,51 +924,51 @@ pub enum Reply { /// yourself with a server which has been setup to /// explicitly deny connections to you. /// - ERR_YOUREBANNEDCREEP(String), + ERR_YOUREBANNEDCREEP(CS<'a>), /// 466 ERR_YOUWILLBEBANNED /// /// - Sent by a server to a user to inform that access to the /// server will soon be denied. /// - ERR_YOUWILLBEBANNED(String), + ERR_YOUWILLBEBANNED(CS<'a>), /// 467 ERR_KEYSET /// " :Channel key already set" - ERR_KEYSET(String), + ERR_KEYSET(CS<'a>), /// 471 ERR_CHANNELISFULL /// " :Cannot join channel (+l)" - ERR_CHANNELISFULL(String), + ERR_CHANNELISFULL(CS<'a>), /// 472 ERR_UNKNOWNMODE /// " :is unknown mode char to me for " - ERR_UNKNOWNMODE(String), + ERR_UNKNOWNMODE(CS<'a>), /// 473 ERR_INVITEONLYCHAN /// " :Cannot join channel (+i)" - ERR_INVITEONLYCHAN(String), + ERR_INVITEONLYCHAN(CS<'a>), /// 474 ERR_BANNEDFROMCHAN /// " :Cannot join channel (+b)" - ERR_BANNEDFROMCHAN(String), + ERR_BANNEDFROMCHAN(CS<'a>), /// 475 ERR_BADCHANNELKEY /// " :Cannot join channel (+k)" - ERR_BADCHANNELKEY(String), + ERR_BADCHANNELKEY(CS<'a>), /// 476 ERR_BADCHANMASK /// " :Bad Channel Mask" - ERR_BADCHANMASK(String), + ERR_BADCHANMASK(CS<'a>), /// 477 ERR_NOCHANMODES /// " :Channel doesn't support modes" - ERR_NOCHANMODES(String), + ERR_NOCHANMODES(CS<'a>), /// 478 ERR_BANLISTFULL /// " :Channel list is full" /// - ERR_BANLISTFULL(String), + ERR_BANLISTFULL(CS<'a>), /// 481 ERR_NOPRIVILEGES /// ":Permission Denied- You're not an IRC operator" @@ -975,7 +977,7 @@ pub enum Reply { /// MUST return this error to indicate the attempt was /// unsuccessful. /// - ERR_NOPRIVILEGES(String), + ERR_NOPRIVILEGES(CS<'a>), /// 482 ERR_CHANOPRIVSNEEDED /// " :You're not channel operator" @@ -985,7 +987,7 @@ pub enum Reply { /// making the attempt is not a chanop on the specified /// channel. /// - ERR_CHANOPRIVSNEEDED(String), + ERR_CHANOPRIVSNEEDED(CS<'a>), /// 483 ERR_CANTKILLSERVER /// ":You can't kill a server!" @@ -994,7 +996,7 @@ pub enum Reply { /// are to be refused and this error returned directly /// to the client. /// - ERR_CANTKILLSERVER(String), + ERR_CANTKILLSERVER(CS<'a>), /// 484 ERR_RESTRICTED /// ":Your connection is restricted!" @@ -1002,7 +1004,7 @@ pub enum Reply { /// - Sent by the server to a user upon connection to indicate /// the restricted nature of the connection (user mode "+r"). /// - ERR_RESTRICTED(String), + ERR_RESTRICTED(CS<'a>), /// 485 ERR_UNIQOPPRIVSNEEDED /// ":You're not the original channel operator" @@ -1011,7 +1013,7 @@ pub enum Reply { /// return this error if the client making the attempt is not /// a chanop on the specified channel. /// - ERR_UNIQOPPRIVSNEEDED(String), + ERR_UNIQOPPRIVSNEEDED(CS<'a>), /// 491 ERR_NOOPERHOST /// ":No O-lines for your host" @@ -1021,7 +1023,7 @@ pub enum Reply { /// client's host as an operator, this error MUST be /// returned. /// - ERR_NOOPERHOST(String), + ERR_NOOPERHOST(CS<'a>), /// 501 ERR_UMODEUNKNOWNFLAG /// ":Unknown MODE flag" @@ -1030,7 +1032,7 @@ pub enum Reply { /// message was sent with a nickname parameter and that /// the a mode flag sent was not recognized. /// - ERR_UMODEUNKNOWNFLAG(String), + ERR_UMODEUNKNOWNFLAG(CS<'a>), /// 502 ERR_USERSDONTMATCH /// ":Cannot change mode for other users" @@ -1038,12 +1040,12 @@ pub enum Reply { /// - Error sent to any user trying to view or change the /// user mode for a user other than themselves. /// - ERR_USERSDONTMATCH(String), + ERR_USERSDONTMATCH(CS<'a>), } -impl<'a> Reply { - pub fn from_message(msg: &'a Message) -> Option { +impl<'a> Reply<'a> { + pub fn from_message(msg: &'a Message) -> Option> { use self::Reply::*; match msg.command() { "001" => msg.elements().last().map(|&e| RPL_WELCOME(Borrowed(e))), -- cgit v1.2.3