diff options
author | Till Hoeppner | 2015-04-18 14:55:40 +0200 |
---|---|---|
committer | Till Hoeppner | 2015-04-18 14:55:40 +0200 |
commit | a8c80253d6361728db95e6a5640a91a341ad4ea5 (patch) | |
tree | 4755946bbf479a294e85457177884988e05c29c0 /src/server.rs | |
parent | bb94e44ed6ec5b55823270192c00904cbfb24b6b (diff) | |
download | irsc-a8c80253d6361728db95e6a5640a91a341ad4ea5.tar.gz irsc-a8c80253d6361728db95e6a5640a91a341ad4ea5.tar.xz irsc-a8c80253d6361728db95e6a5640a91a341ad4ea5.zip |
Fix Option/Result confusions + fixes for stability
Diffstat (limited to 'src/server.rs')
-rw-r--r-- | src/server.rs | 18 |
1 files changed, 9 insertions, 9 deletions
diff --git a/src/server.rs b/src/server.rs index 9c4bb65..dfe5051 100644 --- a/src/server.rs +++ b/src/server.rs @@ -2,7 +2,7 @@ use std::io::{ self, Write, Read, - BufRead, +// BufRead, BufReader, }; @@ -69,7 +69,7 @@ impl Server { pub fn connect(&mut self, host: String, port: u16) -> ::Result<()> { let s = &mut self.stream; match *s { Some(_) => return Err(::IrscError::AlreadyConnected), _ => () }; - *s = match TcpStream::connect((host.as_slice(), port)) { + *s = match TcpStream::connect((host.as_ref(), port)) { Ok(tcp) => Some(StreamKind::Plain(tcp)), Err(e) => return Err(::IrscError::Io(e)) }; @@ -81,7 +81,7 @@ impl Server { pub fn connect_ssl(&mut self, host: String, port: u16) -> ::Result<()> { let mut s = self.stream.lock(); match *s { Some(_) => return Err(::IrscError::AlreadyConnected), _ => () }; - let tcp_stream = match TcpStream::connect((host.as_slice(), port)) { + let tcp_stream = match TcpStream::connect((host.as_ref(), port)) { Ok(tcp) => Some(tcp), Err(e) => return Err(::IrscError::Io(e)) }; @@ -123,27 +123,27 @@ impl Server { } pub fn join(&mut self, channel: &str) -> ::Result<usize> { - self.sendraw(format!("JOIN {}", channel).as_slice(), true) + self.sendraw(format!("JOIN {}", channel).as_ref(), true) } pub fn part(&mut self, channel: &str) -> ::Result<usize> { - self.sendraw(format!("PART {}", channel).as_slice(), true) + self.sendraw(format!("PART {}", channel).as_ref(), true) } pub fn nick(&mut self, nick: &str) -> ::Result<usize> { - self.sendraw(format!("NICK {}", nick).as_slice(), true) + self.sendraw(format!("NICK {}", nick).as_ref(), true) } pub fn user(&mut self, username: &str, hostname: &str, servername: &str, realname: &str) -> ::Result<usize> { - self.sendraw(format!("USER {} {} {} :{}", username, hostname, servername, realname).as_slice(), true) + self.sendraw(format!("USER {} {} {} :{}", username, hostname, servername, realname).as_ref(), true) } pub fn password(&mut self, password: &str) -> ::Result<usize> { - self.sendraw(format!("PASS {}", password).as_slice(), true) + self.sendraw(format!("PASS {}", password).as_ref(), true) } pub fn msg(&mut self, target: &str, message: &str) -> ::Result<usize> { - self.sendraw(format!("PRIVMSG {} :{}", target, message).as_slice(), true) + self.sendraw(format!("PRIVMSG {} :{}", target, message).as_ref(), true) } pub fn listen(&mut self, events: &[fn(&mut Server, &Message)]) -> ::Result<()> { |