diff --git a/src/lib.rs b/src/lib.rs index 7c3b67a..1f63c48 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -40,13 +40,13 @@ impl IrcRead for IrcStream { let mut message: Option = None; while message == None { let mut temp_buf = [0; 512]; - self.stream.read(&mut temp_buf); + self.stream.read(&mut temp_buf)?; self.buffer.push_str(std::str::from_utf8(&temp_buf)?); match self.buffer.find("\r\n") { Some(i) => { let mut raw_message = self.buffer.clone(); // This returns the part after the line break to the buffer. - self.buffer = raw_message.split_off(i); + self.buffer = raw_message.split_off(i+2); message = Some(Message::from(raw_message.as_str())); }, None => (), @@ -71,7 +71,7 @@ impl IrcWrite for IrcStream { } impl IrcStream { - fn new(stream: S) -> Self { + pub fn new(stream: S) -> Self { Self{ stream, buffer: String::new()