Compare commits

...

2 commits

View file

@ -40,13 +40,13 @@ impl<S: Read + Write> IrcRead for IrcStream<S> {
let mut message: Option<Message> = 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 => (),