summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJesse Luehrs <doy@tozt.net>2014-09-09 14:52:39 -0400
committerJesse Luehrs <doy@tozt.net>2014-09-09 14:52:39 -0400
commit0ed3107270494e6c780066a22f532941869e19f2 (patch)
treeab7b3f332561dd77253f20788e59c228e91140e2
parent2dc11043a4403e07c00bf9402e72dcf777f3a310 (diff)
downloadrust-irc-0ed3107270494e6c780066a22f532941869e19f2.tar.gz
rust-irc-0ed3107270494e6c780066a22f532941869e19f2.zip
move callbacks out to their own trait
this reduces the amount of things users have to worry about reimplementing, since we don't have associated items yet
-rw-r--r--examples/client.rs35
-rw-r--r--src/client.rs366
-rw-r--r--src/lib.rs2
3 files changed, 201 insertions, 202 deletions
diff --git a/examples/client.rs b/examples/client.rs
index 236b07e..5b874bb 100644
--- a/examples/client.rs
+++ b/examples/client.rs
@@ -1,38 +1,15 @@
extern crate irc;
use irc::constants::Pong;
-use irc::Client;
-use std::io;
+pub struct ExampleClient;
-struct ExampleClient {
- builder: irc::ClientBuilder<ExampleClient>,
- conn: io::BufferedStream<io::TcpStream>,
- socket_name: Option<String>,
-}
-
-impl irc::Client for ExampleClient {
- fn new (builder: irc::ClientBuilder<ExampleClient>, conn: io::BufferedStream<io::TcpStream>, socket_name: Option<String>) -> ExampleClient {
- ExampleClient { builder: builder, conn: conn, socket_name: socket_name }
- }
- fn builder (&self) -> &irc::ClientBuilder<ExampleClient> {
- &self.builder
- }
- fn conn (&mut self) -> &mut io::BufferedStream<io::TcpStream> {
- &mut self.conn
- }
- fn socket_name (&self) -> Option<&str> {
- match self.socket_name {
- Some(ref name) => Some(name.as_slice()),
- None => None,
- }
- }
-
- fn on_any_message (_client: &mut ExampleClient, m: &irc::Message) {
+impl irc::ClientCallbacks for ExampleClient {
+ fn on_any_message (&mut self, _client: &mut irc::Client, m: &irc::Message) {
print!("{}", m.to_protocol_string());
}
- fn on_ping (client: &mut ExampleClient, _from: Option<&str>, server1: &str, server2: Option<&str>) {
+ fn on_ping (&mut self, client: &mut irc::Client, _from: Option<&str>, server1: &str, server2: Option<&str>) {
let params = match server2 {
Some(server2) => vec![server1.to_string(), server2.to_string()],
None => vec![server1.to_string()],
@@ -43,6 +20,6 @@ impl irc::Client for ExampleClient {
fn main () {
let builder = irc::ClientBuilder::new("doytest", "chat.freenode.net");
- let client: ExampleClient = builder.connect();
- client.run_loop();
+ let client = builder.connect();
+ client.run_loop_with_callbacks(ExampleClient);
}
diff --git a/src/client.rs b/src/client.rs
index b1c455d..b98471b 100644
--- a/src/client.rs
+++ b/src/client.rs
@@ -46,7 +46,7 @@ use constants::{
};
use message::Message;
-pub struct ClientBuilder<T: Client> {
+pub struct ClientBuilder {
nick: String,
pass: Option<String>,
realname: String,
@@ -58,8 +58,8 @@ pub struct ClientBuilder<T: Client> {
port: u16,
}
-impl<T: Client> ClientBuilder<T> {
- pub fn new (nick: &str, servername: &str) -> ClientBuilder<T> {
+impl ClientBuilder {
+ pub fn new (nick: &str, servername: &str) -> ClientBuilder {
ClientBuilder {
nick: nick.to_string(),
pass: None,
@@ -73,32 +73,32 @@ impl<T: Client> ClientBuilder<T> {
}
}
- pub fn set_pass (&mut self, pass: &str) -> &mut ClientBuilder<T> {
+ pub fn set_pass (&mut self, pass: &str) -> &mut ClientBuilder {
self.pass = Some(pass.to_string());
self
}
- pub fn set_username (&mut self, username: &str) -> &mut ClientBuilder<T> {
+ pub fn set_username (&mut self, username: &str) -> &mut ClientBuilder {
self.username = username.to_string();
self
}
- pub fn set_realname (&mut self, realname: &str) -> &mut ClientBuilder<T> {
+ pub fn set_realname (&mut self, realname: &str) -> &mut ClientBuilder {
self.realname = realname.to_string();
self
}
- pub fn set_hostname (&mut self, hostname: &str) -> &mut ClientBuilder<T> {
+ pub fn set_hostname (&mut self, hostname: &str) -> &mut ClientBuilder {
self.hostname = Some(hostname.to_string());
self
}
- pub fn set_port (&mut self, port: u16) -> &mut ClientBuilder<T> {
+ pub fn set_port (&mut self, port: u16) -> &mut ClientBuilder {
self.port = port;
self
}
- pub fn connect (self) -> T {
+ pub fn connect (self) -> Client {
let stream = io::TcpStream::connect(self.servername.as_slice(), self.port);
let mut stream = stream.unwrap();
let socket_name = match stream.socket_name() {
@@ -109,13 +109,30 @@ impl<T: Client> ClientBuilder<T> {
}
}
-pub trait Client {
- fn new (builder: ClientBuilder<Self>, conn: io::BufferedStream<io::TcpStream>, socket_name: Option<String>) -> Self;
- fn builder (&self) -> &ClientBuilder<Self>;
- fn conn (&mut self) -> &mut io::BufferedStream<io::TcpStream>;
- fn socket_name (&self) -> Option<&str>;
+pub struct Client {
+ builder: ClientBuilder,
+ conn: io::BufferedStream<io::TcpStream>,
+ socket_name: Option<String>,
+}
- fn read (&mut self) -> Message {
+impl Client {
+ pub fn new (builder: ClientBuilder, conn: io::BufferedStream<io::TcpStream>, socket_name: Option<String>) -> Client {
+ Client { builder: builder, conn: conn, socket_name: socket_name }
+ }
+ pub fn builder (&self) -> &ClientBuilder {
+ &self.builder
+ }
+ pub fn conn (&mut self) -> &mut io::BufferedStream<io::TcpStream> {
+ &mut self.conn
+ }
+ pub fn socket_name (&self) -> Option<&str> {
+ match self.socket_name {
+ Some(ref name) => Some(name.as_slice()),
+ None => None,
+ }
+ }
+
+ pub fn read (&mut self) -> Message {
// \n isn't valid inside a message, so this should be fine. if the \n
// we find isn't preceded by a \r, this will be caught by the message
// parser.
@@ -125,26 +142,31 @@ pub trait Client {
Message::parse(str::from_utf8(buf.unwrap().as_slice()).unwrap()).unwrap()
}
- fn write (&mut self, msg: Message) {
+ pub fn write (&mut self, msg: Message) {
msg.write_protocol_string(self.conn());
}
- fn run_loop_with (mut self, handler: |&mut Self, &Message|) -> Self {
+ pub fn run_loop (&mut self, handler: |&mut Client, &Message|) {
loop {
let m = self.read();
- handler(&mut self, &m);
+ handler(self, &m);
}
- self
}
+ pub fn run_loop_with_callbacks<T: ClientCallbacks> (mut self, cbs: T) {
+ cbs.run_loop(&mut self)
+ }
+}
+
+pub trait ClientCallbacks {
// XXX once storing closures in structs works, we'll also want to provide
// a default CallbackClient impl of Client to allow users to not have to
// worry about the struct layout for simple cases.
- fn run_loop (mut self) {
- Client::on_client_connect(&mut self);
+ fn run_loop (mut self, client: &mut Client) {
+ self.on_client_connect(client);
- let mut client = self.run_loop_with(|client, m| {
- Client::on_any_message(client, m);
+ client.run_loop(|client, m| {
+ self.on_any_message(client, m);
let from = m.from().as_ref().map(|s| s.as_slice());
let p = m.params().as_slice();
@@ -152,12 +174,12 @@ pub trait Client {
Pass => {
match (p.get(0),) {
(Some(ref pass),) => {
- Client::on_pass(
+ self.on_pass(
client, from,
pass.as_slice()
)
},
- _ => Client::on_invalid_message(client, m),
+ _ => self.on_invalid_message(client, m),
}
},
Nick => {
@@ -165,33 +187,33 @@ pub trait Client {
(Some(ref nick), Some(ref hopcount)) => {
match from_str(hopcount.as_slice()) {
Some(i) => {
- Client::on_nick(
+ self.on_nick(
client, from,
nick.as_slice(), Some(i)
)
},
- _ => Client::on_invalid_message(client, m),
+ _ => self.on_invalid_message(client, m),
}
},
(Some(ref nick), None) => {
- Client::on_nick(
+ self.on_nick(
client, from,
nick.as_slice(), None
)
},
- _ => Client::on_invalid_message(client, m),
+ _ => self.on_invalid_message(client, m),
}
},
User => {
match (p.get(0), p.get(1), p.get(2), p.get(3)) {
(Some(user), Some(host), Some(server), Some(real)) => {
- Client::on_user(
+ self.on_user(
client, from,
user.as_slice(), host.as_slice(),
server.as_slice(), real.as_slice()
)
},
- _ => Client::on_invalid_message(client, m),
+ _ => self.on_invalid_message(client, m),
}
},
Server => {
@@ -199,30 +221,30 @@ pub trait Client {
(Some(ref name), Some(ref hopcount), Some(ref info)) => {
match from_str(hopcount.as_slice()) {
Some(i) => {
- Client::on_server(
+ self.on_server(
client, from,
name.as_slice(), i, info.as_slice()
)
},
- _ => Client::on_invalid_message(client, m),
+ _ => self.on_invalid_message(client, m),
}
},
- _ => Client::on_invalid_message(client, m),
+ _ => self.on_invalid_message(client, m),
}
},
Oper => {
match (p.get(0), p.get(1)) {
(Some(ref user), Some(ref pass)) => {
- Client::on_oper(
+ self.on_oper(
client, from,
user.as_slice(), pass.as_slice()
)
},
- _ => Client::on_invalid_message(client, m),
+ _ => self.on_invalid_message(client, m),
}
},
Quit => {
- Client::on_quit(
+ self.on_quit(
client, from,
p.get(0).map(|s| s.as_slice())
)
@@ -230,90 +252,90 @@ pub trait Client {
Squit => {
match (p.get(0), p.get(1)) {
(Some(ref server), Some(ref comment)) => {
- Client::on_squit(
+ self.on_squit(
client, from,
server.as_slice(), comment.as_slice()
)
},
- _ => Client::on_invalid_message(client, m),
+ _ => self.on_invalid_message(client, m),
}
},
Join => {
match (p.get(0), p.get(1)) {
(Some(ref channels), Some(ref keys)) => {
- Client::on_join(
+ self.on_join(
client, from,
channels.as_slice().split(',').collect(),
keys.as_slice().split(',').collect()
)
},
(Some(ref channels), None) => {
- Client::on_join(
+ self.on_join(
client, from,
channels.as_slice().split(',').collect(),
vec![]
)
},
- _ => Client::on_invalid_message(client, m),
+ _ => self.on_invalid_message(client, m),
}
},
Part => {
match (p.get(0),) {
(Some(ref channels),) => {
- Client::on_part(
+ self.on_part(
client, from,
channels.as_slice().split(',').collect()
)
},
- _ => Client::on_invalid_message(client, m),
+ _ => self.on_invalid_message(client, m),
}
},
Mode => {
match (p.get(0), p.get(1)) {
(Some(name), Some(modes))
if is_channel(name.as_slice()) => {
- Client::on_channel_mode(
+ self.on_channel_mode(
client, from,
name.as_slice(), modes.as_slice(),
p.slice_from(2).iter().map(|s| s.as_slice()).collect()
)
},
(Some(name), Some(modes)) => {
- Client::on_user_mode(
+ self.on_user_mode(
client, from,
name.as_slice(), modes.as_slice()
)
},
- _ => Client::on_invalid_message(client, m),
+ _ => self.on_invalid_message(client, m),
}
},
Topic => {
match (p.get(0), p.get(1)) {
(Some(ref channel), Some(ref topic)) => {
- Client::on_topic(
+ self.on_topic(
client, from,
channel.as_slice(), Some(topic.as_slice())
)
},
(Some(ref channel), None) => {
- Client::on_topic(
+ self.on_topic(
client, from,
channel.as_slice(), None
)
},
- _ => Client::on_invalid_message(client, m),
+ _ => self.on_invalid_message(client, m),
}
},
Names => {
match (p.get(0),) {
(Some(ref channels),) => {
- Client::on_names(
+ self.on_names(
client, from,
channels.as_slice().split(',').collect()
)
},
_ => {
- Client::on_names(
+ self.on_names(
client, from,
vec![]
)
@@ -323,21 +345,21 @@ pub trait Client {
List => {
match (p.get(0), p.get(1)) {
(Some(ref channels), Some(ref server)) => {
- Client::on_list(
+ self.on_list(
client, from,
channels.as_slice().split(',').collect(),
Some(server.as_slice())
)
},
(Some(ref channels), None) => {
- Client::on_list(
+ self.on_list(
client, from,
channels.as_slice().split(',').collect(),
None
)
},
_ => {
- Client::on_list(
+ self.on_list(
client, from,
vec![], None
)
@@ -347,35 +369,35 @@ pub trait Client {
Invite => {
match (p.get(0), p.get(1)) {
(Some(ref nickname), Some(ref channel)) => {
- Client::on_invite(
+ self.on_invite(
client, from,
nickname.as_slice(), channel.as_slice()
)
},
- _ => Client::on_invalid_message(client, m),
+ _ => self.on_invalid_message(client, m),
}
},
Kick => {
match (p.get(0), p.get(1), p.get(2)) {
(Some(ref channel), Some(ref user), Some(ref comment)) => {
- Client::on_kick(
+ self.on_kick(
client, from,
channel.as_slice(), user.as_slice(),
Some(comment.as_slice())
)
},
(Some(ref channel), Some(ref user), None) => {
- Client::on_kick(
+ self.on_kick(
client, from,
channel.as_slice(), user.as_slice(),
None
)
},
- _ => Client::on_invalid_message(client, m),
+ _ => self.on_invalid_message(client, m),
}
},
Version => {
- Client::on_version(
+ self.on_version(
client, from,
p.get(0).map(|s| s.as_slice())
)
@@ -383,19 +405,19 @@ pub trait Client {
Stats => {
match (p.get(0), p.get(1)) {
(Some(ref query), Some(ref server)) => {
- Client::on_stats(
+ self.on_stats(
client, from,
Some(query.as_slice()), Some(server.as_slice())
)
},
(Some(ref query), None) => {
- Client::on_stats(
+ self.on_stats(
client, from,
Some(query.as_slice()), None
)
},
_ => {
- Client::on_stats(
+ self.on_stats(
client, from,
None, None
)
@@ -405,19 +427,19 @@ pub trait Client {
Links => {
match (p.get(0), p.get(1)) {
(Some(ref server), Some(ref mask)) => {
- Client::on_stats(
+ self.on_stats(
client, from,
Some(server.as_slice()), Some(mask.as_slice())
)
},
(Some(ref mask), None) => {
- Client::on_stats(
+ self.on_stats(
client, from,
None, Some(mask.as_slice())
)
},
_ => {
- Client::on_stats(
+ self.on_stats(
client, from,
None, None
)
@@ -425,7 +447,7 @@ pub trait Client {
}
},
Time => {
- Client::on_time(
+ self.on_time(
client, from,
p.get(0).map(|s| s.as_slice())
)
@@ -435,54 +457,54 @@ pub trait Client {
(Some(ref server), Some(ref port), Some(ref remote)) => {
match from_str(port.as_slice()) {
Some(port) => {
- Client::on_connect(
+ self.on_connect(
client, from,
server.as_slice(),
Some(port),
Some(remote.as_slice())
)
},
- _ => Client::on_invalid_message(client, m),
+ _ => self.on_invalid_message(client, m),
}
},
(Some(ref server), Some(ref port), None) => {
match from_str(port.as_slice()) {
Some(port) => {
- Client::on_connect(
+ self.on_connect(
client, from,
server.as_slice(),
Some(port),
None
)
},
- _ => Client::on_invalid_message(client, m),
+ _ => self.on_invalid_message(client, m),
}
},
(Some(ref server), None, None) => {
- Client::on_connect(
+ self.on_connect(
client, from,
server.as_slice(),
None,
None
)
},
- _ => Client::on_invalid_message(client, m),
+ _ => self.on_invalid_message(client, m),
}
},
Trace => {
- Client::on_trace(
+ self.on_trace(
client, from,
p.get(0).map(|s| s.as_slice())
)
},
Admin => {
- Client::on_admin(
+ self.on_admin(
client, from,
p.get(0).map(|s| s.as_slice())
)
},
Info => {
- Client::on_info(
+ self.on_info(
client, from,
p.get(0).map(|s| s.as_slice())
)
@@ -490,25 +512,25 @@ pub trait Client {
Privmsg => {
match (p.get(0), p.get(1)) {
(Some(ref receivers), Some(ref text)) => {
- Client::on_privmsg(
+ self.on_privmsg(
client, from,
receivers.as_slice().split(',').collect(),
text.as_slice()
)
},
- _ => Client::on_invalid_message(client, m),
+ _ => self.on_invalid_message(client, m),
}
},
Notice => {
match (p.get(0), p.get(1)) {
(Some(ref nickname), Some(ref text)) => {
- Client::on_notice(
+ self.on_notice(
client, from,
nickname.as_slice(),
text.as_slice()
)
},
- _ => Client::on_invalid_message(client, m),
+ _ => self.on_invalid_message(client, m),
}
},
Who => {
@@ -516,42 +538,42 @@ pub trait Client {
(Some(ref name), Some(ref o)) => {
match o.as_slice() {
"o" => {
- Client::on_who(
+ self.on_who(
client, from,
name.as_slice(),
true
)
},
- _ => Client::on_invalid_message(client, m),
+ _ => self.on_invalid_message(client, m),
}
},
(Some(ref name), None) => {
- Client::on_who(
+ self.on_who(
client, from,
name.as_slice(),
false
)
},
- _ => Client::on_invalid_message(client, m),
+ _ => self.on_invalid_message(client, m),
}
},
Whois => {
match (p.get(0), p.get(1)) {
(Some(ref server), Some(ref nickmasks)) => {
- Client::on_whois(
+ self.on_whois(
client, from,
Some(server.as_slice()),
nickmasks.as_slice().split(',').collect()
)
},
(Some(ref nickmasks), None) => {
- Client::on_whois(
+ self.on_whois(
client, from,
None,
nickmasks.as_slice().split(',').collect()
)
},
- _ => Client::on_invalid_message(client, m),
+ _ => self.on_invalid_message(client, m),
}
},
Whowas => {
@@ -559,138 +581,138 @@ pub trait Client {
(Some(ref nickname), Some(count), Some(ref server)) => {
match from_str(count.as_slice()) {
Some(i) => {
- Client::on_whowas(
+ self.on_whowas(
client, from,
nickname.as_slice(),
Some(i),
Some(server.as_slice()),
)
},
- _ => Client::on_invalid_message(client, m),
+ _ => self.on_invalid_message(client, m),
}
},
(Some(ref nickname), Some(count), None) => {
match from_str(count.as_slice()) {
Some(i) => {
- Client::on_whowas(
+ self.on_whowas(
client, from,
nickname.as_slice(),
Some(i),
None
)
},
- _ => Client::on_invalid_message(client, m),
+ _ => self.on_invalid_message(client, m),
}
},
(Some(ref nickname), None, None) => {
- Client::on_whowas(
+ self.on_whowas(
client, from,
nickname.as_slice(),
None,
None
)
},
- _ => Client::on_invalid_message(client, m),
+ _ => self.on_invalid_message(client, m),
}
},
Kill => {
match (p.get(0), p.get(1)) {
(Some(ref nickname), Some(ref comment)) => {
- Client::on_kill(
+ self.on_kill(
client, from,
nickname.as_slice(),
comment.as_slice()
)
},
- _ => Client::on_invalid_message(client, m),
+ _ => self.on_invalid_message(client, m),
}
},
Ping => {
match (p.get(0), p.get(1)) {
(Some(ref server1), Some(ref server2)) => {
- Client::on_ping(
+ self.on_ping(
client, from,
server1.as_slice(),
Some(server2.as_slice())
)
},
(Some(ref server1), None) => {
- Client::on_ping(
+ self.on_ping(
client, from,
server1.as_slice(),
None
)
},
- _ => Client::on_invalid_message(client, m),
+ _ => self.on_invalid_message(client, m),
}
},
Pong => {
match (p.get(0), p.get(1)) {
(Some(ref daemon1), Some(ref daemon2)) => {
- Client::on_pong(
+ self.on_pong(
client, from,
daemon1.as_slice(),
Some(daemon2.as_slice())
)
},
(Some(ref daemon1), None) => {
- Client::on_ping(
+ self.on_ping(
client, from,
daemon1.as_slice(),
None
)
},
- _ => Client::on_invalid_message(client, m),
+ _ => self.on_invalid_message(client, m),
}
},
Error => {
match (p.get(0),) {
(Some(ref message),) => {
- Client::on_error(
+ self.on_error(
client, from,
message.as_slice()
)
},
- _ => Client::on_invalid_message(client, m),
+ _ => self.on_invalid_message(client, m),
}
},
Away => {
- Client::on_away(
+ self.on_away(
client, from,
p.get(0).map(|s| s.as_slice())
)
},
Rehash => {
- Client::on_rehash(
+ self.on_rehash(
client, from
)
},
Restart => {
- Client::on_restart(
+ self.on_restart(
client, from
)
},
Summon => {
match (p.get(0), p.get(1)) {
(Some(ref user), Some(ref server)) => {
- Client::on_summon(
+ self.on_summon(
client, from,
user.as_slice(),
Some(server.as_slice())
)
},
(Some(ref user), None) => {
- Client::on_summon(
+ self.on_summon(
client, from,
user.as_slice(),
None
)
},
- _ => Client::on_invalid_message(client, m),
+ _ => self.on_invalid_message(client, m),
}
},
Users => {
- Client::on_users(
+ self.on_users(
client, from,
p.get(0).map(|s| s.as_slice())
)
@@ -698,38 +720,38 @@ pub trait Client {
Wallops => {
match (p.get(0),) {
(Some(ref text),) => {
- Client::on_wallops(
+ self.on_wallops(
client, from,
text.as_slice()
)
},
- _ => Client::on_invalid_message(client, m),
+ _ => self.on_invalid_message(client, m),
}
},
Userhost => {
match (p.get(0),) {
(Some(_),) => {
- Client::on_userhost(
+ self.on_userhost(
client, from,
m.params().iter().map(|s| s.as_slice()).collect::<Vec<&str>>().as_slice()
)
},
- _ => Client::on_invalid_message(client, m),
+ _ => self.on_invalid_message(client, m),
}
},
Ison => {
match (p.get(0),) {
(Some(_),) => {
- Client::on_userhost(
+ self.on_userhost(
client, from,
m.params().iter().map(|s| s.as_slice()).collect::<Vec<&str>>().as_slice()
)
},
- _ => Client::on_invalid_message(client, m),
+ _ => self.on_invalid_message(client, m),
}
},
RawCommand(_) => {
- Client::on_unknown_message(client, m)
+ self.on_unknown_message(client, m)
},
Reply(_) => {
// XXX
@@ -737,10 +759,10 @@ pub trait Client {
}
});
- Client::on_client_disconnect(&mut client);
+ self.on_client_disconnect(client);
}
- fn on_client_connect (client: &mut Self) {
+ fn on_client_connect (&mut self, client: &mut Client) {
let nick = client.builder().nick.clone();
let pass = client.builder().pass.clone();
let username = client.builder().username.clone();
@@ -773,58 +795,58 @@ pub trait Client {
)
);
}
- #[allow(unused_variable)] fn on_client_disconnect (client: &mut Self) { }
-
- #[allow(unused_variable)] fn on_any_message (client: &mut Self, m: &Message) { }
- #[allow(unused_variable)] fn on_invalid_message (client: &mut Self, m: &Message) { }
- #[allow(unused_variable)] fn on_unknown_message (client: &mut Self, m: &Message) { }
-
- #[allow(unused_variable)] fn on_pass (client: &mut Self, from: Option<&str>, pass: &str) { }
- #[allow(unused_variable)] fn on_nick (client: &mut Self, from: Option<&str>, nick: &str, hopcount: Option<u32>) { }
- #[allow(unused_variable)] fn on_user (client: &mut Self, from: Option<&str>, username: &str, hostname: &str, servername: &str, realname: &str) { }
- #[allow(unused_variable)] fn on_server (client: &mut Self, from: Option<&str>, servername: &str, hopcount: u32, info: &str) { }
- #[allow(unused_variable)] fn on_oper (client: &mut Self, from: Option<&str>, user: &str, pass: &str) { }
- #[allow(unused_variable)] fn on_quit (client: &mut Self, from: Option<&str>, msg: Option<&str>) { }
- #[allow(unused_variable)] fn on_squit (client: &mut Self, from: Option<&str>, server: &str, comment: &str) { }
-
- #[allow(unused_variable)] fn on_join (client: &mut Self, from: Option<&str>, channels: Vec<&str>, keys: Vec<&str>) { }
- #[allow(unused_variable)] fn on_part (client: &mut Self, from: Option<&str>, channels: Vec<&str>) { }
- #[allow(unused_variable)] fn on_channel_mode (client: &mut Self, from: Option<&str>, channel: &str, modes: &str, params: Vec<&str>) { }
- #[allow(unused_variable)] fn on_user_mode (client: &mut Self, from: Option<&str>, nickname: &str, modes: &str) { }
- #[allow(unused_variable)] fn on_topic (client: &mut Self, from: Option<&str>, channel: &str, topic: Option<&str>) { }
- #[allow(unused_variable)] fn on_names (client: &mut Self, from: Option<&str>, channels: Vec<&str>) { }
- #[allow(unused_variable)] fn on_list (client: &mut Self, from: Option<&str>, channels: Vec<&str>, server: Option<&str>) { }
- #[allow(unused_variable)] fn on_invite (client: &mut Self, from: Option<&str>, nickname: &str, channel: &str) { }
- #[allow(unused_variable)] fn on_kick (client: &mut Self, from: Option<&str>, channel: &str, user: &str, comment: Option<&str>) { }
-
- #[allow(unused_variable)] fn on_version (client: &mut Self, from: Option<&str>, server: Option<&str>) { }
- #[allow(unused_variable)] fn on_stats (client: &mut Self, from: Option<&str>, query: Option<&str>, server: Option<&str>) { }
- #[allow(unused_variable)] fn on_links (client: &mut Self, from: Option<&str>, remote_server: Option<&str>, server_mask: Option<&str>) { }
- #[allow(unused_variable)] fn on_time (client: &mut Self, from: Option<&str>, server: Option<&str>) { }
- #[allow(unused_variable)] fn on_connect (client: &mut Self, from: Option<&str>, target_server: &str, port: Option<u16>, remote_server: Option<&str>) { }
- #[allow(unused_variable)] fn on_trace (client: &mut Self, from: Option<&str>, server: Option<&str>) { }
- #[allow(unused_variable)] fn on_admin (client: &mut Self, from: Option<&str>, server: Option<&str>) { }
- #[allow(unused_variable)] fn on_info (client: &mut Self, from: Option<&str>, server: Option<&str>) { }
-
- #[allow(unused_variable)] fn on_privmsg (client: &mut Self, from: Option<&str>, receivers: Vec<&str>, text: &str) { }
- #[allow(unused_variable)] fn on_notice (client: &mut Self, from: Option<&str>, nickname: &str, text: &str) { }
- #[allow(unused_variable)] fn on_who (client: &mut Self, from: Option<&str>, name: &str, o: bool) { }
- #[allow(unused_variable)] fn on_whois (client: &mut Self, from: Option<&str>, server: Option<&str>, nickmasks: Vec<&str>) { }
- #[allow(unused_variable)] fn on_whowas (client: &mut Self, from: Option<&str>, nickname: &str, count: Option<u32>, server: Option<&str>) { }
-
- #[allow(unused_variable)] fn on_kill (client: &mut Self, from: Option<&str>, nickname: &str, comment: &str) { }
- #[allow(unused_variable)] fn on_ping (client: &mut Self, from: Option<&str>, server1: &str, server2: Option<&str>) { }
- #[allow(unused_variable)] fn on_pong (client: &mut Self, from: Option<&str>, daemon1: &str, daemon2: Option<&str>) { }
- #[allow(unused_variable)] fn on_error (client: &mut Self, from: Option<&str>, message: &str) { }
-
- #[allow(unused_variable)] fn on_away (client: &mut Self, from: Option<&str>, message: Option<&str>) { }
- #[allow(unused_variable)] fn on_rehash (client: &mut Self, from: Option<&str>) { }
- #[allow(unused_variable)] fn on_restart (client: &mut Self, from: Option<&str>) { }
- #[allow(unused_variable)] fn on_summon (client: &mut Self, from: Option<&str>, user: &str, server: Option<&str>) { }
- #[allow(unused_variable)] fn on_users (client: &mut Self, from: Option<&str>, server: Option<&str>) { }
- #[allow(unused_variable)] fn on_wallops (client: &mut Self, from: Option<&str>, text: &str) { }
- #[allow(unused_variable)] fn on_userhost (client: &mut Self, from: Option<&str>, nicknames: &[&str]) { }
- #[allow(unused_variable)] fn on_ison (client: &mut Self, from: Option<&str>, nicknames: &[&str]) { }
+ #[allow(unused_variable)] fn on_client_disconnect (&mut self, client: &mut Client) { }
+
+ #[allow(unused_variable)] fn on_any_message (&mut self, client: &mut Client, m: &Message) { }
+ #[allow(unused_variable)] fn on_invalid_message (&mut self, client: &mut Client, m: &Message) { }
+ #[allow(unused_variable)] fn on_unknown_message (&mut self, client: &mut Client, m: &Message) { }
+
+ #[allow(unused_variable)] fn on_pass (&mut self, client: &mut Client, from: Option<&str>, pass: &str) { }
+ #[allow(unused_variable)] fn on_nick (&mut self, client: &mut Client, from: Option<&str>, nick: &str, hopcount: Option<u32>) { }
+ #[allow(unused_variable)] fn on_user (&mut self, client: &mut Client, from: Option<&str>, username: &str, hostname: &str, servername: &str, realname: &str) { }
+ #[allow(unused_variable)] fn on_server (&mut self, client: &mut Client, from: Option<&str>, servername: &str, hopcount: u32, info: &str) { }
+ #[allow(unused_variable)] fn on_oper (&mut self, client: &mut Client, from: Option<&str>, user: &str, pass: &str) { }
+ #[allow(unused_variable)] fn on_quit (&mut self, client: &mut Client, from: Option<&str>, msg: Option<&str>) { }
+ #[allow(unused_variable)] fn on_squit (&mut self, client: &mut Client, from: Option<&str>, server: &str, comment: &str) { }
+
+ #[allow(unused_variable)] fn on_join (&mut self, client: &mut Client, from: Option<&str>, channels: Vec<&str>, keys: Vec<&str>) { }
+ #[allow(unused_variable)] fn on_part (&mut self, client: &mut Client, from: Option<&str>, channels: Vec<&str>) { }
+ #[allow(unused_variable)] fn on_channel_mode (&mut self, client: &mut Client, from: Option<&str>, channel: &str, modes: &str, params: Vec<&str>) { }
+ #[allow(unused_variable)] fn on_user_mode (&mut self, client: &mut Client, from: Option<&str>, nickname: &str, modes: &str) { }
+ #[allow(unused_variable)] fn on_topic (&mut self, client: &mut Client, from: Option<&str>, channel: &str, topic: Option<&str>) { }
+ #[allow(unused_variable)] fn on_names (&mut self, client: &mut Client, from: Option<&str>, channels: Vec<&str>) { }
+ #[allow(unused_variable)] fn on_list (&mut self, client: &mut Client, from: Option<&str>, channels: Vec<&str>, server: Option<&str>) { }
+ #[allow(unused_variable)] fn on_invite (&mut self, client: &mut Client, from: Option<&str>, nickname: &str, channel: &str) { }
+ #[allow(unused_variable)] fn on_kick (&mut self, client: &mut Client, from: Option<&str>, channel: &str, user: &str, comment: Option<&str>) { }
+
+ #[allow(unused_variable)] fn on_version (&mut self, client: &mut Client, from: Option<&str>, server: Option<&str>) { }
+ #[allow(unused_variable)] fn on_stats (&mut self, client: &mut Client, from: Option<&str>, query: Option<&str>, server: Option<&str>) { }
+ #[allow(unused_variable)] fn on_links (&mut self, client: &mut Client, from: Option<&str>, remote_server: Option<&str>, server_mask: Option<&str>) { }
+ #[allow(unused_variable)] fn on_time (&mut self, client: &mut Client, from: Option<&str>, server: Option<&str>) { }
+ #[allow(unused_variable)] fn on_connect (&mut self, client: &mut Client, from: Option<&str>, target_server: &str, port: Option<u16>, remote_server: Option<&str>) { }
+ #[allow(unused_variable)] fn on_trace (&mut self, client: &mut Client, from: Option<&str>, server: Option<&str>) { }
+ #[allow(unused_variable)] fn on_admin (&mut self, client: &mut Client, from: Option<&str>, server: Option<&str>) { }
+ #[allow(unused_variable)] fn on_info (&mut self, client: &mut Client, from: Option<&str>, server: Option<&str>) { }
+
+ #[allow(unused_variable)] fn on_privmsg (&mut self, client: &mut Client, from: Option<&str>, receivers: Vec<&str>, text: &str) { }
+ #[allow(unused_variable)] fn on_notice (&mut self, client: &mut Client, from: Option<&str>, nickname: &str, text: &str) { }
+ #[allow(unused_variable)] fn on_who (&mut self, client: &mut Client, from: Option<&str>, name: &str, o: bool) { }
+ #[allow(unused_variable)] fn on_whois (&mut self, client: &mut Client, from: Option<&str>, server: Option<&str>, nickmasks: Vec<&str>) { }
+ #[allow(unused_variable)] fn on_whowas (&mut self, client: &mut Client, from: Option<&str>, nickname: &str, count: Option<u32>, server: Option<&str>) { }
+
+ #[allow(unused_variable)] fn on_kill (&mut self, client: &mut Client, from: Option<&str>, nickname: &str, comment: &str) { }
+ #[allow(unused_variable)] fn on_ping (&mut self, client: &mut Client, from: Option<&str>, server1: &str, server2: Option<&str>) { }
+ #[allow(unused_variable)] fn on_pong (&mut self, client: &mut Client, from: Option<&str>, daemon1: &str, daemon2: Option<&str>) { }
+ #[allow(unused_variable)] fn on_error (&mut self, client: &mut Client, from: Option<&str>, message: &str) { }
+
+ #[allow(unused_variable)] fn on_away (&mut self, client: &mut Client, from: Option<&str>, message: Option<&str>) { }
+ #[allow(unused_variable)] fn on_rehash (&mut self, client: &mut Client, from: Option<&str>) { }
+ #[allow(unused_variable)] fn on_restart (&mut self, client: &mut Client, from: Option<&str>) { }
+ #[allow(unused_variable)] fn on_summon (&mut self, client: &mut Client, from: Option<&str>, user: &str, server: Option<&str>) { }
+ #[allow(unused_variable)] fn on_users (&mut self, client: &mut Client, from: Option<&str>, server: Option<&str>) { }
+ #[allow(unused_variable)] fn on_wallops (&mut self, client: &mut Client, from: Option<&str>, text: &str) { }
+ #[allow(unused_variable)] fn on_userhost (&mut self, client: &mut Client, from: Option<&str>, nicknames: &[&str]) { }
+ #[allow(unused_variable)] fn on_ison (&mut self, client: &mut Client, from: Option<&str>, nicknames: &[&str]) { }
}
fn is_channel (name: &str) -> bool {
diff --git a/src/lib.rs b/src/lib.rs
index 847f013..e4128c1 100644
--- a/src/lib.rs
+++ b/src/lib.rs
@@ -3,7 +3,7 @@
#[phase(plugin)] extern crate regex_macros;
extern crate regex;
-pub use client::{Client, ClientBuilder};
+pub use client::{Client, ClientBuilder, ClientCallbacks};
pub use message::Message;
pub mod client;