Propagate errors in Input::packets().
This commit is contained in:

committed by
Josh Holmer

parent
fa2b8d13ad
commit
05bad6e9e0
@ -159,24 +159,22 @@ impl<'a> PacketIter<'a> {
|
||||
}
|
||||
|
||||
impl<'a> Iterator for PacketIter<'a> {
|
||||
type Item = (Stream<'a>, Packet);
|
||||
type Item = Result<(Stream<'a>, Packet), Error>;
|
||||
|
||||
fn next(&mut self) -> Option<<Self as Iterator>::Item> {
|
||||
let mut packet = Packet::empty();
|
||||
|
||||
loop {
|
||||
match packet.read(self.context) {
|
||||
Ok(..) => unsafe {
|
||||
return Some((
|
||||
Stream::wrap(mem::transmute_copy(&self.context), packet.stream()),
|
||||
packet,
|
||||
));
|
||||
},
|
||||
match packet.read(self.context) {
|
||||
Ok(..) => unsafe {
|
||||
Some(Ok((
|
||||
Stream::wrap(mem::transmute_copy(&self.context), packet.stream()),
|
||||
packet,
|
||||
)))
|
||||
},
|
||||
|
||||
Err(Error::Eof) => return None,
|
||||
Err(Error::Eof) => None,
|
||||
|
||||
Err(..) => (),
|
||||
}
|
||||
Err(e) => Some(Err(e)),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user