aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorTill Hoeppner2015-06-27 23:40:38 +0200
committerTill Hoeppner2015-06-27 23:40:38 +0200
commit577a0662897efb105ab794444fbeb62c783c3b16 (patch)
treeeec1b164c6698f6b3055ce65cfb05d16d76cf7aa /src
parent1e1dd0b217b627ce24ce280c5cf5e9dd27a38ba2 (diff)
downloadirsc-577a0662897efb105ab794444fbeb62c783c3b16.tar.gz
irsc-577a0662897efb105ab794444fbeb62c783c3b16.tar.xz
irsc-577a0662897efb105ab794444fbeb62c783c3b16.zip
Add to_static functionality for Replies
Diffstat (limited to 'src')
-rw-r--r--src/client.rs32
-rw-r--r--src/command.rs12
-rw-r--r--src/lib.rs2
-rw-r--r--src/reply.rs416
4 files changed, 304 insertions, 158 deletions
diff --git a/src/client.rs b/src/client.rs
index 84841d4..80f68e2 100644
--- a/src/client.rs
+++ b/src/client.rs
@@ -8,7 +8,7 @@ use std::io::{
use std::net::TcpStream;
use std::borrow::Cow::{ self, Borrowed, Owned };
-use std::sync::{ Arc, Mutex };
+use std::sync::{ Arc, RwLock };
use carboxyl::{ Stream, Sink };
@@ -193,7 +193,7 @@ impl OwnedClient {
pub fn into_shared(self) -> SharedClient {
SharedClient {
- client: Arc::new(Mutex::new(self)),
+ client: Arc::new(RwLock::new(self)),
}
}
@@ -208,14 +208,14 @@ impl Client for OwnedClient {
#[derive(Clone)]
pub struct SharedClient {
- client: Arc<Mutex<OwnedClient>>,
+ client: Arc<RwLock<OwnedClient>>,
}
impl SharedClient {
pub fn messages(&self) -> Stream<(SharedClient, Message)> {
let cl = SharedClient { client: self.client.clone() };
- self.client.lock().unwrap().messages()
- .map(move |m| (cl.clone(), m))
+ self.client.read().unwrap().messages()
+ .map(move |m| { println!("Message!"); (cl.clone(), m) })
}
pub fn events(&self) -> Stream<(SharedClient, Message, Arc<Event<'static>>)> {
@@ -228,14 +228,28 @@ impl SharedClient {
})
}
-// pub fn commands(&self) -> Stream<Command> {
-// self.messages().filter_map(|msg| Command::from_message(&msg).map(|c| c.to_static()))
-// }
+ pub fn listen(&self) -> Result<()> {
+ self.client.write().unwrap().listen()
+ }
+
+ pub fn commands(&self) -> Stream<(SharedClient, Message, Command<'static>)> {
+ self.messages().filter_map(|(cl, msg)| match Command::from_message(&msg) {
+ Some(m) => Some((cl, msg.clone(), m.to_static())),
+ None => None
+ })
+ }
+
+ pub fn replies(&self) -> Stream<(SharedClient, Message, Reply<'static>)> {
+ self.messages().filter_map(|(cl, msg)| match Reply::from_message(&msg) {
+ Some(m) => Some((cl, msg.clone(), m.to_static())),
+ None => None
+ })
+ }
}
impl Client for SharedClient {
fn send_message(&mut self, msg: Message) -> Result<()> {
- if let Ok(mut guard) = self.client.lock() {
+ if let Ok(mut guard) = self.client.write() {
guard.send_raw(&msg.to_string())
} else { Result(Ok(())) }
}
diff --git a/src/command.rs b/src/command.rs
index 6f849d9..9ed95d7 100644
--- a/src/command.rs
+++ b/src/command.rs
@@ -1876,18 +1876,6 @@ impl<'a> Command<'a> {
Message::format(None, Borrowed("PING"), vec![s1.clone()], s2.clone(), MsgType::Irc),
&PONG(ref s1, ref s2) =>
Message::format(None, Borrowed("PONG"), vec![s1.clone()], s2.clone(), MsgType::Irc),
- /*&Command::PING(ref server1, ref server2) => {
- let mut c = Vec::new();
- c.push(server1.clone());
- if let &Some(ref s) = server2 { c.push(s.clone()) }
- Message::format(None, "PING", c, None, MsgType::Irc)
- },
- &Command::PONG(ref server1, ref server2) => {
- let mut c = Vec::new();
- c.push(server1.clone());
- if let &Some(ref s) = server2 { c.push(s.clone()) }
- Message::format(None, "PONG", c, None, MsgType::Irc)
- },*/
_ => unimplemented!()
}
}
diff --git a/src/lib.rs b/src/lib.rs
index c9dade4..32f153d 100644
--- a/src/lib.rs
+++ b/src/lib.rs
@@ -33,7 +33,7 @@ pub use message::{ Message, MsgType };
pub use command::Command;
pub use reply::Reply;
pub use event::Event;
-pub use client::Client;
+pub use client::{ Client, OwnedClient, SharedClient };
#[derive(Debug)]
pub enum IrscError {
diff --git a/src/reply.rs b/src/reply.rs
index f7c09e6..7b594ff 100644
--- a/src/reply.rs
+++ b/src/reply.rs
@@ -1049,142 +1049,142 @@ impl<'a> Reply<'a> {
use self::Reply::*;
match msg.command() {
"001" => msg.elements().last().map(|&e| RPL_WELCOME(Borrowed(e))),
- /*"002" => Ok(RPL_YOURHOST),
- "003" => Ok(RPL_CREATED),
- "004" => Ok(RPL_MYINFO),
- "005" => Ok(RPL_BOUNCE),
- "302" => Ok(RPL_USERHOST),
- "303" => Ok(RPL_ISON),
- "301" => Ok(RPL_AWAY),
- "305" => Ok(RPL_UNAWAY),
- "306" => Ok(RPL_NOWAWAY),
- "311" => Ok(RPL_WHOISUSER),
- "312" => Ok(RPL_WHOISSERVER),
- "313" => Ok(RPL_WHOISOPERATOR),
- "317" => Ok(RPL_WHOISIDLE),
- "318" => Ok(RPL_ENDOFWHOIS),
- "319" => Ok(RPL_WHOISCHANNELS),
- "314" => Ok(RPL_WHOWASUSER),
- "369" => Ok(RPL_ENDOFWHOWAS),
- "321" => Ok(RPL_LISTSTART),
- "322" => Ok(RPL_LIST),
- "323" => Ok(RPL_LISTEND),
- "325" => Ok(RPL_UNIQOPIS),
- "324" => Ok(RPL_CHANNELMODEIS),
- "331" => Ok(RPL_NOTOPIC),
- "332" => Ok(RPL_TOPIC),
- "341" => Ok(RPL_INVITING),
- "342" => Ok(RPL_SUMMONING),
- "346" => Ok(RPL_INVITELIST),
- "347" => Ok(RPL_ENDOFINVITELIST),
- "348" => Ok(RPL_EXCEPTLIST),
- "349" => Ok(RPL_ENDOFEXCEPTLIST),
- "351" => Ok(RPL_VERSION),
- "352" => Ok(RPL_WHOREPLY),
- "315" => Ok(RPL_ENDOFWHO),
- "353" => Ok(RPL_NAMREPLY),
- "366" => Ok(RPL_ENDOFNAMES),
- "364" => Ok(RPL_LINKS),
- "365" => Ok(RPL_ENDOFLINKS),
- "367" => Ok(RPL_BANLIST),
- "368" => Ok(RPL_ENDOFBANLIST),
- "371" => Ok(RPL_INFO),
- "374" => Ok(RPL_ENDOFINFO),
- "375" => Ok(RPL_MOTDSTART),
- "372" => Ok(RPL_MOTD),
- "376" => Ok(RPL_ENDOFMOTD),
- "381" => Ok(RPL_YOUREOPER),
- "382" => Ok(RPL_REHASHING),
- "383" => Ok(RPL_YOURESERVICE),
- "391" => Ok(RPL_TIME),
- "392" => Ok(RPL_USERSSTART),
- "393" => Ok(RPL_USERS),
- "394" => Ok(RPL_ENDOFUSERS),
- "395" => Ok(RPL_NOUSERS),
- "200" => Ok(RPL_TRACELINK),
- "201" => Ok(RPL_TRACECONNECTING),
- "202" => Ok(RPL_TRACEHANDSHAKE),
- "203" => Ok(RPL_TRACEUNKNOWN),
- "204" => Ok(RPL_TRACEOPERATOR),
- "205" => Ok(RPL_TRACEUSER),
- "206" => Ok(RPL_TRACESERVER),
- "207" => Ok(RPL_TRACESERVICE),
- "208" => Ok(RPL_TRACENEWTYPE),
- "209" => Ok(RPL_TRACECLASS),
- "210" => Ok(RPL_TRACERECONNECT),
- "261" => Ok(RPL_TRACELOG),
- "262" => Ok(RPL_TRACEEND),
- "211" => Ok(RPL_STATSLINKINFO),
- "212" => Ok(RPL_STATSCOMMANDS),
- "219" => Ok(RPL_ENDOFSTATS),
- "242" => Ok(RPL_STATSUPTIME),
- "243" => Ok(RPL_STATSOLINE),
- "221" => Ok(RPL_UMODEIS),
- "234" => Ok(RPL_SERVLIST),
- "235" => Ok(RPL_SERVLISTEND),
- "251" => Ok(RPL_LUSERCLIENT),
- "252" => Ok(RPL_LUSEROP),
- "253" => Ok(RPL_LUSERUNKNOWN),
- "254" => Ok(RPL_LUSERCHANNELS),
- "255" => Ok(RPL_LUSERME),
- "256" => Ok(RPL_ADMINME),
- "257" => Ok(RPL_ADMINLOC1),
- "258" => Ok(RPL_ADMINLOC2),
- "259" => Ok(RPL_ADMINEMAIL),
- "263" => Ok(RPL_TRYAGAIN),
- "401" => Ok(ERR_NOSUCHNICK),
- "402" => Ok(ERR_NOSUCHSERVER),
- "403" => Ok(ERR_NOSUCHCHANNEL),
- "404" => Ok(ERR_CANNOTSENDTOCHAN),
- "405" => Ok(ERR_TOOMANYCHANNELS),
- "406" => Ok(ERR_WASNOSUCHNICK),
- "407" => Ok(ERR_TOOMANYTARGETS),
- "408" => Ok(ERR_NOSUCHSERVICE),
- "409" => Ok(ERR_NOORIGIN),
- "411" => Ok(ERR_NORECIPIENT),
- "412" => Ok(ERR_NOTEXTTOSEND),
- "413" => Ok(ERR_NOTOPLEVEL),
- "414" => Ok(ERR_WILDTOPLEVEL),
- "415" => Ok(ERR_BADMASK),
- "421" => Ok(ERR_UNKNOWNCOMMAND),
- "422" => Ok(ERR_NOMOTD),
- "423" => Ok(ERR_NOADMININFO),
- "424" => Ok(ERR_FILEERROR),
- "431" => Ok(ERR_NONICKNAMEGIVEN),
- "432" => Ok(ERR_ERRONEUSNICKNAME),
- "433" => Ok(ERR_NICKNAMEINUSE),
- "436" => Ok(ERR_NICKCOLLISION),
- "437" => Ok(ERR_UNAVAILRESOURCE),
- "441" => Ok(ERR_USERNOTINCHANNEL),
- "442" => Ok(ERR_NOTONCHANNEL),
- "443" => Ok(ERR_USERONCHANNEL),
- "444" => Ok(ERR_NOLOGIN),
- "445" => Ok(ERR_SUMMONDISABLED),
- "446" => Ok(ERR_USERSDISABLED),
- "451" => Ok(ERR_NOTREGISTERED),
- "461" => Ok(ERR_NEEDMOREPARAMS),
- "462" => Ok(ERR_ALREADYREGISTRED),
- "463" => Ok(ERR_NOPERMFORHOST),
- "464" => Ok(ERR_PASSWDMISMATCH),
- "465" => Ok(ERR_YOUREBANNEDCREEP),
- "466" => Ok(ERR_YOUWILLBEBANNED),
- "467" => Ok(ERR_KEYSET),
- "471" => Ok(ERR_CHANNELISFULL),
- "472" => Ok(ERR_UNKNOWNMODE),
- "473" => Ok(ERR_INVITEONLYCHAN),
- "474" => Ok(ERR_BANNEDFROMCHAN),
- "475" => Ok(ERR_BADCHANNELKEY),
- "476" => Ok(ERR_BADCHANMASK),
- "477" => Ok(ERR_NOCHANMODES),
- "478" => Ok(ERR_BANLISTFULL),
- "481" => Ok(ERR_NOPRIVILEGES),
- "482" => Ok(ERR_CHANOPRIVSNEEDED),
- "483" => Ok(ERR_CANTKILLSERVER),
- "484" => Ok(ERR_RESTRICTED),
- "485" => Ok(ERR_UNIQOPPRIVSNEEDED),
- "491" => Ok(ERR_NOOPERHOST),
- "501" => Ok(ERR_UMODEUNKNOWNFLAG),
- "502" => Ok(ERR_USERSDONTMATCH),*/
+ "002" => msg.elements().last().map(|&e| RPL_YOURHOST(Borrowed(e))),
+ "003" => msg.elements().last().map(|&e| RPL_CREATED(Borrowed(e))),
+ "004" => msg.elements().last().map(|&e| RPL_MYINFO(Borrowed(e))),
+ "005" => msg.elements().last().map(|&e| RPL_BOUNCE(Borrowed(e))),
+ "302" => msg.elements().last().map(|&e| RPL_USERHOST(Borrowed(e))),
+ "303" => msg.elements().last().map(|&e| RPL_ISON(Borrowed(e))),
+ "301" => msg.elements().last().map(|&e| RPL_AWAY(Borrowed(e))),
+ "305" => msg.elements().last().map(|&e| RPL_UNAWAY(Borrowed(e))),
+ "306" => msg.elements().last().map(|&e| RPL_NOWAWAY(Borrowed(e))),
+ "311" => msg.elements().last().map(|&e| RPL_WHOISUSER(Borrowed(e))),
+ "312" => msg.elements().last().map(|&e| RPL_WHOISSERVER(Borrowed(e))),
+ "313" => msg.elements().last().map(|&e| RPL_WHOISOPERATOR(Borrowed(e))),
+ "317" => msg.elements().last().map(|&e| RPL_WHOISIDLE(Borrowed(e))),
+ "318" => msg.elements().last().map(|&e| RPL_ENDOFWHOIS(Borrowed(e))),
+ "319" => msg.elements().last().map(|&e| RPL_WHOISCHANNELS(Borrowed(e))),
+ "314" => msg.elements().last().map(|&e| RPL_WHOWASUSER(Borrowed(e))),
+ "369" => msg.elements().last().map(|&e| RPL_ENDOFWHOWAS(Borrowed(e))),
+ "321" => Some(RPL_LISTSTART),
+ "322" => msg.elements().last().map(|&e| RPL_LIST(Borrowed(e))),
+ "323" => msg.elements().last().map(|&e| RPL_LISTEND(Borrowed(e))),
+ "325" => msg.elements().last().map(|&e| RPL_UNIQOPIS(Borrowed(e))),
+ "324" => msg.elements().last().map(|&e| RPL_CHANNELMODEIS(Borrowed(e))),
+ "331" => msg.elements().last().map(|&e| RPL_NOTOPIC(Borrowed(e))),
+ "332" => msg.elements().last().map(|&e| RPL_TOPIC(Borrowed(e))),
+ "341" => msg.elements().last().map(|&e| RPL_INVITING(Borrowed(e))),
+ "342" => msg.elements().last().map(|&e| RPL_SUMMONING(Borrowed(e))),
+ "346" => msg.elements().last().map(|&e| RPL_INVITELIST(Borrowed(e))),
+ "347" => msg.elements().last().map(|&e| RPL_ENDOFINVITELIST(Borrowed(e))),
+ "348" => msg.elements().last().map(|&e| RPL_EXCEPTLIST(Borrowed(e))),
+ "349" => msg.elements().last().map(|&e| RPL_ENDOFEXCEPTLIST(Borrowed(e))),
+ "351" => msg.elements().last().map(|&e| RPL_VERSION(Borrowed(e))),
+ "352" => msg.elements().last().map(|&e| RPL_WHOREPLY(Borrowed(e))),
+ "315" => msg.elements().last().map(|&e| RPL_ENDOFWHO(Borrowed(e))),
+ "353" => msg.elements().last().map(|&e| RPL_NAMREPLY(Borrowed(e))),
+ "366" => msg.elements().last().map(|&e| RPL_ENDOFNAMES(Borrowed(e))),
+ "364" => msg.elements().last().map(|&e| RPL_LINKS(Borrowed(e))),
+ "365" => msg.elements().last().map(|&e| RPL_ENDOFLINKS(Borrowed(e))),
+ "367" => msg.elements().last().map(|&e| RPL_BANLIST(Borrowed(e))),
+ "368" => msg.elements().last().map(|&e| RPL_ENDOFBANLIST(Borrowed(e))),
+ "371" => msg.elements().last().map(|&e| RPL_INFO(Borrowed(e))),
+ "374" => msg.elements().last().map(|&e| RPL_ENDOFINFO(Borrowed(e))),
+ "375" => msg.elements().last().map(|&e| RPL_MOTDSTART(Borrowed(e))),
+ "372" => msg.elements().last().map(|&e| RPL_MOTD(Borrowed(e))),
+ "376" => msg.elements().last().map(|&e| RPL_ENDOFMOTD(Borrowed(e))),
+ "381" => msg.elements().last().map(|&e| RPL_YOUREOPER(Borrowed(e))),
+ "382" => msg.elements().last().map(|&e| RPL_REHASHING(Borrowed(e))),
+ "383" => msg.elements().last().map(|&e| RPL_YOURESERVICE(Borrowed(e))),
+ "391" => msg.elements().last().map(|&e| RPL_TIME(Borrowed(e))),
+ "392" => msg.elements().last().map(|&e| RPL_USERSSTART(Borrowed(e))),
+ "393" => msg.elements().last().map(|&e| RPL_USERS(Borrowed(e))),
+ "394" => msg.elements().last().map(|&e| RPL_ENDOFUSERS(Borrowed(e))),
+ "395" => msg.elements().last().map(|&e| RPL_NOUSERS(Borrowed(e))),
+ "200" => msg.elements().last().map(|&e| RPL_TRACELINK(Borrowed(e))),
+ "201" => msg.elements().last().map(|&e| RPL_TRACECONNECTING(Borrowed(e))),
+ "202" => msg.elements().last().map(|&e| RPL_TRACEHANDSHAKE(Borrowed(e))),
+ "203" => msg.elements().last().map(|&e| RPL_TRACEUNKNOWN(Borrowed(e))),
+ "204" => msg.elements().last().map(|&e| RPL_TRACEOPERATOR(Borrowed(e))),
+ "205" => msg.elements().last().map(|&e| RPL_TRACEUSER(Borrowed(e))),
+ "206" => msg.elements().last().map(|&e| RPL_TRACESERVER(Borrowed(e))),
+ "207" => msg.elements().last().map(|&e| RPL_TRACESERVICE(Borrowed(e))),
+ "208" => msg.elements().last().map(|&e| RPL_TRACENEWTYPE(Borrowed(e))),
+ "209" => msg.elements().last().map(|&e| RPL_TRACECLASS(Borrowed(e))),
+ "210" => msg.elements().last().map(|&e| RPL_TRACERECONNECT(Borrowed(e))),
+ "261" => msg.elements().last().map(|&e| RPL_TRACELOG(Borrowed(e))),
+ "262" => msg.elements().last().map(|&e| RPL_TRACEEND(Borrowed(e))),
+ "211" => msg.elements().last().map(|&e| RPL_STATSLINKINFO(Borrowed(e))),
+ "212" => msg.elements().last().map(|&e| RPL_STATSCOMMANDS(Borrowed(e))),
+ "219" => msg.elements().last().map(|&e| RPL_ENDOFSTATS(Borrowed(e))),
+ "242" => msg.elements().last().map(|&e| RPL_STATSUPTIME(Borrowed(e))),
+ "243" => msg.elements().last().map(|&e| RPL_STATSOLINE(Borrowed(e))),
+ "221" => msg.elements().last().map(|&e| RPL_UMODEIS(Borrowed(e))),
+ "234" => msg.elements().last().map(|&e| RPL_SERVLIST(Borrowed(e))),
+ "235" => msg.elements().last().map(|&e| RPL_SERVLISTEND(Borrowed(e))),
+ "251" => msg.elements().last().map(|&e| RPL_LUSERCLIENT(Borrowed(e))),
+ "252" => msg.elements().last().map(|&e| RPL_LUSEROP(Borrowed(e))),
+ "253" => msg.elements().last().map(|&e| RPL_LUSERUNKNOWN(Borrowed(e))),
+ "254" => msg.elements().last().map(|&e| RPL_LUSERCHANNELS(Borrowed(e))),
+ "255" => msg.elements().last().map(|&e| RPL_LUSERME(Borrowed(e))),
+ "256" => msg.elements().last().map(|&e| RPL_ADMINME(Borrowed(e))),
+ "257" => msg.elements().last().map(|&e| RPL_ADMINLOC1(Borrowed(e))),
+ "258" => msg.elements().last().map(|&e| RPL_ADMINLOC2(Borrowed(e))),
+ "259" => msg.elements().last().map(|&e| RPL_ADMINEMAIL(Borrowed(e))),
+ "263" => msg.elements().last().map(|&e| RPL_TRYAGAIN(Borrowed(e))),
+ "401" => msg.elements().last().map(|&e| ERR_NOSUCHNICK(Borrowed(e))),
+ "402" => msg.elements().last().map(|&e| ERR_NOSUCHSERVER(Borrowed(e))),
+ "403" => msg.elements().last().map(|&e| ERR_NOSUCHCHANNEL(Borrowed(e))),
+ "404" => msg.elements().last().map(|&e| ERR_CANNOTSENDTOCHAN(Borrowed(e))),
+ "405" => msg.elements().last().map(|&e| ERR_TOOMANYCHANNELS(Borrowed(e))),
+ "406" => msg.elements().last().map(|&e| ERR_WASNOSUCHNICK(Borrowed(e))),
+ "407" => msg.elements().last().map(|&e| ERR_TOOMANYTARGETS(Borrowed(e))),
+ "408" => msg.elements().last().map(|&e| ERR_NOSUCHSERVICE(Borrowed(e))),
+ "409" => msg.elements().last().map(|&e| ERR_NOORIGIN(Borrowed(e))),
+ "411" => msg.elements().last().map(|&e| ERR_NORECIPIENT(Borrowed(e))),
+ "412" => msg.elements().last().map(|&e| ERR_NOTEXTTOSEND(Borrowed(e))),
+ "413" => msg.elements().last().map(|&e| ERR_NOTOPLEVEL(Borrowed(e))),
+ "414" => msg.elements().last().map(|&e| ERR_WILDTOPLEVEL(Borrowed(e))),
+ "415" => msg.elements().last().map(|&e| ERR_BADMASK(Borrowed(e))),
+ "421" => msg.elements().last().map(|&e| ERR_UNKNOWNCOMMAND(Borrowed(e))),
+ "422" => msg.elements().last().map(|&e| ERR_NOMOTD(Borrowed(e))),
+ "423" => msg.elements().last().map(|&e| ERR_NOADMININFO(Borrowed(e))),
+ "424" => msg.elements().last().map(|&e| ERR_FILEERROR(Borrowed(e))),
+ "431" => msg.elements().last().map(|&e| ERR_NONICKNAMEGIVEN(Borrowed(e))),
+ "432" => msg.elements().last().map(|&e| ERR_ERRONEUSNICKNAME(Borrowed(e))),
+ "433" => msg.elements().last().map(|&e| ERR_NICKNAMEINUSE(Borrowed(e))),
+ "436" => msg.elements().last().map(|&e| ERR_NICKCOLLISION(Borrowed(e))),
+ "437" => msg.elements().last().map(|&e| ERR_UNAVAILRESOURCE(Borrowed(e))),
+ "441" => msg.elements().last().map(|&e| ERR_USERNOTINCHANNEL(Borrowed(e))),
+ "442" => msg.elements().last().map(|&e| ERR_NOTONCHANNEL(Borrowed(e))),
+ "443" => msg.elements().last().map(|&e| ERR_USERONCHANNEL(Borrowed(e))),
+ "444" => msg.elements().last().map(|&e| ERR_NOLOGIN(Borrowed(e))),
+ "445" => msg.elements().last().map(|&e| ERR_SUMMONDISABLED(Borrowed(e))),
+ "446" => msg.elements().last().map(|&e| ERR_USERSDISABLED(Borrowed(e))),
+ "451" => msg.elements().last().map(|&e| ERR_NOTREGISTERED(Borrowed(e))),
+ "461" => msg.elements().last().map(|&e| ERR_NEEDMOREPARAMS(Borrowed(e))),
+ "462" => msg.elements().last().map(|&e| ERR_ALREADYREGISTRED(Borrowed(e))),
+ "463" => msg.elements().last().map(|&e| ERR_NOPERMFORHOST(Borrowed(e))),
+ "464" => msg.elements().last().map(|&e| ERR_PASSWDMISMATCH(Borrowed(e))),
+ "465" => msg.elements().last().map(|&e| ERR_YOUREBANNEDCREEP(Borrowed(e))),
+ "466" => msg.elements().last().map(|&e| ERR_YOUWILLBEBANNED(Borrowed(e))),
+ "467" => msg.elements().last().map(|&e| ERR_KEYSET(Borrowed(e))),
+ "471" => msg.elements().last().map(|&e| ERR_CHANNELISFULL(Borrowed(e))),
+ "472" => msg.elements().last().map(|&e| ERR_UNKNOWNMODE(Borrowed(e))),
+ "473" => msg.elements().last().map(|&e| ERR_INVITEONLYCHAN(Borrowed(e))),
+ "474" => msg.elements().last().map(|&e| ERR_BANNEDFROMCHAN(Borrowed(e))),
+ "475" => msg.elements().last().map(|&e| ERR_BADCHANNELKEY(Borrowed(e))),
+ "476" => msg.elements().last().map(|&e| ERR_BADCHANMASK(Borrowed(e))),
+ "477" => msg.elements().last().map(|&e| ERR_NOCHANMODES(Borrowed(e))),
+ "478" => msg.elements().last().map(|&e| ERR_BANLISTFULL(Borrowed(e))),
+ "481" => msg.elements().last().map(|&e| ERR_NOPRIVILEGES(Borrowed(e))),
+ "482" => msg.elements().last().map(|&e| ERR_CHANOPRIVSNEEDED(Borrowed(e))),
+ "483" => msg.elements().last().map(|&e| ERR_CANTKILLSERVER(Borrowed(e))),
+ "484" => msg.elements().last().map(|&e| ERR_RESTRICTED(Borrowed(e))),
+ "485" => msg.elements().last().map(|&e| ERR_UNIQOPPRIVSNEEDED(Borrowed(e))),
+ "491" => msg.elements().last().map(|&e| ERR_NOOPERHOST(Borrowed(e))),
+ "501" => msg.elements().last().map(|&e| ERR_UMODEUNKNOWNFLAG(Borrowed(e))),
+ "502" => msg.elements().last().map(|&e| ERR_USERSDONTMATCH(Borrowed(e))),
_ => None
}
}
@@ -1331,4 +1331,148 @@ impl<'a> Reply<'a> {
&ERR_USERSDONTMATCH(ref s) => Message::format(None, Borrowed("502"), vec![], Some(s.clone()), MsgType::Irc),
}
}
+
+ pub fn to_static(&self) -> Reply<'static> {
+ use self::Reply::*;
+ match self {
+ &RPL_WELCOME(ref s) => RPL_WELCOME(Cow::Owned(s.clone().into_owned())),
+ &RPL_YOURHOST(ref s) => RPL_YOURHOST(Cow::Owned(s.clone().into_owned())),
+ &RPL_CREATED(ref s) => RPL_CREATED(Cow::Owned(s.clone().into_owned())),
+ &RPL_MYINFO(ref s) => RPL_MYINFO(Cow::Owned(s.clone().into_owned())),
+ &RPL_BOUNCE(ref s) => RPL_BOUNCE(Cow::Owned(s.clone().into_owned())),
+ &RPL_USERHOST(ref s) => RPL_USERHOST(Cow::Owned(s.clone().into_owned())),
+ &RPL_ISON(ref s) => RPL_ISON(Cow::Owned(s.clone().into_owned())),
+ &RPL_AWAY(ref s) => RPL_AWAY(Cow::Owned(s.clone().into_owned())),
+ &RPL_UNAWAY(ref s) => RPL_UNAWAY(Cow::Owned(s.clone().into_owned())),
+ &RPL_NOWAWAY(ref s) => RPL_NOWAWAY(Cow::Owned(s.clone().into_owned())),
+ &RPL_WHOISUSER(ref s) => RPL_WHOISUSER(Cow::Owned(s.clone().into_owned())),
+ &RPL_WHOISSERVER(ref s) => RPL_WHOISSERVER(Cow::Owned(s.clone().into_owned())),
+ &RPL_WHOISOPERATOR(ref s) => RPL_WHOISOPERATOR(Cow::Owned(s.clone().into_owned())),
+ &RPL_WHOISIDLE(ref s) => RPL_WHOISIDLE(Cow::Owned(s.clone().into_owned())),
+ &RPL_ENDOFWHOIS(ref s) => RPL_ENDOFWHOIS(Cow::Owned(s.clone().into_owned())),
+ &RPL_WHOISCHANNELS(ref s) => RPL_WHOISCHANNELS(Cow::Owned(s.clone().into_owned())),
+ &RPL_WHOWASUSER(ref s) => RPL_WHOWASUSER(Cow::Owned(s.clone().into_owned())),
+ &RPL_ENDOFWHOWAS(ref s) => RPL_ENDOFWHOWAS(Cow::Owned(s.clone().into_owned())),
+ &RPL_LISTSTART => RPL_LISTSTART,
+ &RPL_LIST(ref s) => RPL_LIST(Cow::Owned(s.clone().into_owned())),
+ &RPL_LISTEND(ref s) => RPL_LISTEND(Cow::Owned(s.clone().into_owned())),
+ &RPL_UNIQOPIS(ref s) => RPL_UNIQOPIS(Cow::Owned(s.clone().into_owned())),
+ &RPL_CHANNELMODEIS(ref s) => RPL_CHANNELMODEIS(Cow::Owned(s.clone().into_owned())),
+ &RPL_NOTOPIC(ref s) => RPL_NOTOPIC(Cow::Owned(s.clone().into_owned())),
+ &RPL_TOPIC(ref s) => RPL_TOPIC(Cow::Owned(s.clone().into_owned())),
+ &RPL_INVITING(ref s) => RPL_INVITING(Cow::Owned(s.clone().into_owned())),
+ &RPL_SUMMONING(ref s) => RPL_SUMMONING(Cow::Owned(s.clone().into_owned())),
+ &RPL_INVITELIST(ref s) => RPL_INVITELIST(Cow::Owned(s.clone().into_owned())),
+ &RPL_ENDOFINVITELIST(ref s) => RPL_ENDOFINVITELIST(Cow::Owned(s.clone().into_owned())),
+ &RPL_EXCEPTLIST(ref s) => RPL_EXCEPTLIST(Cow::Owned(s.clone().into_owned())),
+ &RPL_ENDOFEXCEPTLIST(ref s) => RPL_ENDOFEXCEPTLIST(Cow::Owned(s.clone().into_owned())),
+ &RPL_VERSION(ref s) => RPL_VERSION(Cow::Owned(s.clone().into_owned())),
+ &RPL_WHOREPLY(ref s) => RPL_WHOREPLY(Cow::Owned(s.clone().into_owned())),
+ &RPL_ENDOFWHO(ref s) => RPL_ENDOFWHO(Cow::Owned(s.clone().into_owned())),
+ &RPL_NAMREPLY(ref s) => RPL_NAMREPLY(Cow::Owned(s.clone().into_owned())),
+ &RPL_ENDOFNAMES(ref s) => RPL_ENDOFNAMES(Cow::Owned(s.clone().into_owned())),
+ &RPL_LINKS(ref s) => RPL_LINKS(Cow::Owned(s.clone().into_owned())),
+ &RPL_ENDOFLINKS(ref s) => RPL_ENDOFLINKS(Cow::Owned(s.clone().into_owned())),
+ &RPL_BANLIST(ref s) => RPL_BANLIST(Cow::Owned(s.clone().into_owned())),
+ &RPL_ENDOFBANLIST(ref s) => RPL_ENDOFBANLIST(Cow::Owned(s.clone().into_owned())),
+ &RPL_INFO(ref s) => RPL_INFO(Cow::Owned(s.clone().into_owned())),
+ &RPL_ENDOFINFO(ref s) => RPL_ENDOFINFO(Cow::Owned(s.clone().into_owned())),
+ &RPL_MOTDSTART(ref s) => RPL_MOTDSTART(Cow::Owned(s.clone().into_owned())),
+ &RPL_MOTD(ref s) => RPL_MOTD(Cow::Owned(s.clone().into_owned())),
+ &RPL_ENDOFMOTD(ref s) => RPL_ENDOFMOTD(Cow::Owned(s.clone().into_owned())),
+ &RPL_YOUREOPER(ref s) => RPL_YOUREOPER(Cow::Owned(s.clone().into_owned())),
+ &RPL_REHASHING(ref s) => RPL_REHASHING(Cow::Owned(s.clone().into_owned())),
+ &RPL_YOURESERVICE(ref s) => RPL_YOURESERVICE(Cow::Owned(s.clone().into_owned())),
+ &RPL_TIME(ref s) => RPL_TIME(Cow::Owned(s.clone().into_owned())),
+ &RPL_USERSSTART(ref s) => RPL_USERSSTART(Cow::Owned(s.clone().into_owned())),
+ &RPL_USERS(ref s) => RPL_USERS(Cow::Owned(s.clone().into_owned())),
+ &RPL_ENDOFUSERS(ref s) => RPL_ENDOFUSERS(Cow::Owned(s.clone().into_owned())),
+ &RPL_NOUSERS(ref s) => RPL_NOUSERS(Cow::Owned(s.clone().into_owned())),
+ &RPL_TRACELINK(ref s) => RPL_TRACELINK(Cow::Owned(s.clone().into_owned())),
+ &RPL_TRACECONNECTING(ref s) => RPL_TRACECONNECTING(Cow::Owned(s.clone().into_owned())),
+ &RPL_TRACEHANDSHAKE(ref s) => RPL_TRACEHANDSHAKE(Cow::Owned(s.clone().into_owned())),
+ &RPL_TRACEUNKNOWN(ref s) => RPL_TRACEUNKNOWN(Cow::Owned(s.clone().into_owned())),
+ &RPL_TRACEOPERATOR(ref s) => RPL_TRACEOPERATOR(Cow::Owned(s.clone().into_owned())),
+ &RPL_TRACEUSER(ref s) => RPL_TRACEUSER(Cow::Owned(s.clone().into_owned())),
+ &RPL_TRACESERVER(ref s) => RPL_TRACESERVER(Cow::Owned(s.clone().into_owned())),
+ &RPL_TRACESERVICE(ref s) => RPL_TRACESERVICE(Cow::Owned(s.clone().into_owned())),
+ &RPL_TRACENEWTYPE(ref s) => RPL_TRACENEWTYPE(Cow::Owned(s.clone().into_owned())),
+ &RPL_TRACECLASS(ref s) => RPL_TRACECLASS(Cow::Owned(s.clone().into_owned())),
+ &RPL_TRACERECONNECT(ref s) => RPL_TRACERECONNECT(Cow::Owned(s.clone().into_owned())),
+ &RPL_TRACELOG(ref s) => RPL_TRACELOG(Cow::Owned(s.clone().into_owned())),
+ &RPL_TRACEEND(ref s) => RPL_TRACEEND(Cow::Owned(s.clone().into_owned())),
+ &RPL_STATSLINKINFO(ref s) => RPL_STATSLINKINFO(Cow::Owned(s.clone().into_owned())),
+ &RPL_STATSCOMMANDS(ref s) => RPL_STATSCOMMANDS(Cow::Owned(s.clone().into_owned())),
+ &RPL_ENDOFSTATS(ref s) => RPL_ENDOFSTATS(Cow::Owned(s.clone().into_owned())),
+ &RPL_STATSUPTIME(ref s) => RPL_STATSUPTIME(Cow::Owned(s.clone().into_owned())),
+ &RPL_STATSOLINE(ref s) => RPL_STATSOLINE(Cow::Owned(s.clone().into_owned())),
+ &RPL_UMODEIS(ref s) => RPL_UMODEIS(Cow::Owned(s.clone().into_owned())),
+ &RPL_SERVLIST(ref s) => RPL_SERVLIST(Cow::Owned(s.clone().into_owned())),
+ &RPL_SERVLISTEND(ref s) => RPL_SERVLISTEND(Cow::Owned(s.clone().into_owned())),
+ &RPL_LUSERCLIENT(ref s) => RPL_LUSERCLIENT(Cow::Owned(s.clone().into_owned())),
+ &RPL_LUSEROP(ref s) => RPL_LUSEROP(Cow::Owned(s.clone().into_owned())),
+ &RPL_LUSERUNKNOWN(ref s) => RPL_LUSERUNKNOWN(Cow::Owned(s.clone().into_owned())),
+ &RPL_LUSERCHANNELS(ref s) => RPL_LUSERCHANNELS(Cow::Owned(s.clone().into_owned())),
+ &RPL_LUSERME(ref s) => RPL_LUSERME(Cow::Owned(s.clone().into_owned())),
+ &RPL_ADMINME(ref s) => RPL_ADMINME(Cow::Owned(s.clone().into_owned())),
+ &RPL_ADMINLOC1(ref s) => RPL_ADMINLOC1(Cow::Owned(s.clone().into_owned())),
+ &RPL_ADMINLOC2(ref s) => RPL_ADMINLOC2(Cow::Owned(s.clone().into_owned())),
+ &RPL_ADMINEMAIL(ref s) => RPL_ADMINEMAIL(Cow::Owned(s.clone().into_owned())),
+ &RPL_TRYAGAIN(ref s) => RPL_TRYAGAIN(Cow::Owned(s.clone().into_owned())),
+ &ERR_NOSUCHNICK(ref s) => ERR_NOSUCHNICK(Cow::Owned(s.clone().into_owned())),
+ &ERR_NOSUCHSERVER(ref s) => ERR_NOSUCHSERVER(Cow::Owned(s.clone().into_owned())),
+ &ERR_NOSUCHCHANNEL(ref s) => ERR_NOSUCHCHANNEL(Cow::Owned(s.clone().into_owned())),
+ &ERR_CANNOTSENDTOCHAN(ref s) => ERR_CANNOTSENDTOCHAN(Cow::Owned(s.clone().into_owned())),
+ &ERR_TOOMANYCHANNELS(ref s) => ERR_TOOMANYCHANNELS(Cow::Owned(s.clone().into_owned())),
+ &ERR_WASNOSUCHNICK(ref s) => ERR_WASNOSUCHNICK(Cow::Owned(s.clone().into_owned())),
+ &ERR_TOOMANYTARGETS(ref s) => ERR_TOOMANYTARGETS(Cow::Owned(s.clone().into_owned())),
+ &ERR_NOSUCHSERVICE(ref s) => ERR_NOSUCHSERVICE(Cow::Owned(s.clone().into_owned())),
+ &ERR_NOORIGIN(ref s) => ERR_NOORIGIN(Cow::Owned(s.clone().into_owned())),
+ &ERR_NORECIPIENT(ref s) => ERR_NORECIPIENT(Cow::Owned(s.clone().into_owned())),
+ &ERR_NOTEXTTOSEND(ref s) => ERR_NOTEXTTOSEND(Cow::Owned(s.clone().into_owned())),
+ &ERR_NOTOPLEVEL(ref s) => ERR_NOTOPLEVEL(Cow::Owned(s.clone().into_owned())),
+ &ERR_WILDTOPLEVEL(ref s) => ERR_WILDTOPLEVEL(Cow::Owned(s.clone().into_owned())),
+ &ERR_BADMASK(ref s) => ERR_BADMASK(Cow::Owned(s.clone().into_owned())),
+ &ERR_UNKNOWNCOMMAND(ref s) => ERR_UNKNOWNCOMMAND(Cow::Owned(s.clone().into_owned())),
+ &ERR_NOMOTD(ref s) => ERR_NOMOTD(Cow::Owned(s.clone().into_owned())),
+ &ERR_NOADMININFO(ref s) => ERR_NOADMININFO(Cow::Owned(s.clone().into_owned())),
+ &ERR_FILEERROR(ref s) => ERR_FILEERROR(Cow::Owned(s.clone().into_owned())),
+ &ERR_NONICKNAMEGIVEN(ref s) => ERR_NONICKNAMEGIVEN(Cow::Owned(s.clone().into_owned())),
+ &ERR_ERRONEUSNICKNAME(ref s) => ERR_ERRONEUSNICKNAME(Cow::Owned(s.clone().into_owned())),
+ &ERR_NICKNAMEINUSE(ref s) => ERR_NICKNAMEINUSE(Cow::Owned(s.clone().into_owned())),
+ &ERR_NICKCOLLISION(ref s) => ERR_NICKCOLLISION(Cow::Owned(s.clone().into_owned())),
+ &ERR_UNAVAILRESOURCE(ref s) => ERR_UNAVAILRESOURCE(Cow::Owned(s.clone().into_owned())),
+ &ERR_USERNOTINCHANNEL(ref s) => ERR_USERNOTINCHANNEL(Cow::Owned(s.clone().into_owned())),
+ &ERR_NOTONCHANNEL(ref s) => ERR_NOTONCHANNEL(Cow::Owned(s.clone().into_owned())),
+ &ERR_USERONCHANNEL(ref s) => ERR_USERONCHANNEL(Cow::Owned(s.clone().into_owned())),
+ &ERR_NOLOGIN(ref s) => ERR_NOLOGIN(Cow::Owned(s.clone().into_owned())),
+ &ERR_SUMMONDISABLED(ref s) => ERR_SUMMONDISABLED(Cow::Owned(s.clone().into_owned())),
+ &ERR_USERSDISABLED(ref s) => ERR_USERSDISABLED(Cow::Owned(s.clone().into_owned())),
+ &ERR_NOTREGISTERED(ref s) => ERR_NOTREGISTERED(Cow::Owned(s.clone().into_owned())),
+ &ERR_NEEDMOREPARAMS(ref s) => ERR_NEEDMOREPARAMS(Cow::Owned(s.clone().into_owned())),
+ &ERR_ALREADYREGISTRED(ref s) => ERR_ALREADYREGISTRED(Cow::Owned(s.clone().into_owned())),
+ &ERR_NOPERMFORHOST(ref s) => ERR_NOPERMFORHOST(Cow::Owned(s.clone().into_owned())),
+ &ERR_PASSWDMISMATCH(ref s) => ERR_PASSWDMISMATCH(Cow::Owned(s.clone().into_owned())),
+ &ERR_YOUREBANNEDCREEP(ref s) => ERR_YOUREBANNEDCREEP(Cow::Owned(s.clone().into_owned())),
+ &ERR_YOUWILLBEBANNED(ref s) => ERR_YOUWILLBEBANNED(Cow::Owned(s.clone().into_owned())),
+ &ERR_KEYSET(ref s) => ERR_KEYSET(Cow::Owned(s.clone().into_owned())),
+ &ERR_CHANNELISFULL(ref s) => ERR_CHANNELISFULL(Cow::Owned(s.clone().into_owned())),
+ &ERR_UNKNOWNMODE(ref s) => ERR_UNKNOWNMODE(Cow::Owned(s.clone().into_owned())),
+ &ERR_INVITEONLYCHAN(ref s) => ERR_INVITEONLYCHAN(Cow::Owned(s.clone().into_owned())),
+ &ERR_BANNEDFROMCHAN(ref s) => ERR_BANNEDFROMCHAN(Cow::Owned(s.clone().into_owned())),
+ &ERR_BADCHANNELKEY(ref s) => ERR_BADCHANNELKEY(Cow::Owned(s.clone().into_owned())),
+ &ERR_BADCHANMASK(ref s) => ERR_BADCHANMASK(Cow::Owned(s.clone().into_owned())),
+ &ERR_NOCHANMODES(ref s) => ERR_NOCHANMODES(Cow::Owned(s.clone().into_owned())),
+ &ERR_BANLISTFULL(ref s) => ERR_BANLISTFULL(Cow::Owned(s.clone().into_owned())),
+ &ERR_NOPRIVILEGES(ref s) => ERR_NOPRIVILEGES(Cow::Owned(s.clone().into_owned())),
+ &ERR_CHANOPRIVSNEEDED(ref s) => ERR_CHANOPRIVSNEEDED(Cow::Owned(s.clone().into_owned())),
+ &ERR_CANTKILLSERVER(ref s) => ERR_CANTKILLSERVER(Cow::Owned(s.clone().into_owned())),
+ &ERR_RESTRICTED(ref s) => ERR_RESTRICTED(Cow::Owned(s.clone().into_owned())),
+ &ERR_UNIQOPPRIVSNEEDED(ref s) => ERR_UNIQOPPRIVSNEEDED(Cow::Owned(s.clone().into_owned())),
+ &ERR_NOOPERHOST(ref s) => ERR_NOOPERHOST(Cow::Owned(s.clone().into_owned())),
+ &ERR_UMODEUNKNOWNFLAG(ref s) => ERR_UMODEUNKNOWNFLAG(Cow::Owned(s.clone().into_owned())),
+ &ERR_USERSDONTMATCH(ref s) => ERR_USERSDONTMATCH(Cow::Owned(s.clone().into_owned())),
+ }
+
+ }
}