diff options
author | Till Hoeppner | 2015-07-28 01:04:59 +0200 |
---|---|---|
committer | Till Hoeppner | 2015-07-28 01:04:59 +0200 |
commit | 434048f7252c2490f04866c9a08eff6eb1688dc3 (patch) | |
tree | bb02d903b0ff36ab72ed7be4032395307efcd909 /src | |
parent | 01703f2dcd807f58c03a83bf1d3fa52e8023a0ad (diff) | |
download | ilc-434048f7252c2490f04866c9a08eff6eb1688dc3.tar.gz ilc-434048f7252c2490f04866c9a08eff6eb1688dc3.tar.xz ilc-434048f7252c2490f04866c9a08eff6eb1688dc3.zip |
Properly handle EOF while reading msgpack markers
If there's no more data, we stop returning events.
This will still error on EOF while reading
msgpack data though, which is sort-of intended.
Diffstat (limited to 'src')
-rw-r--r-- | src/format/msgpack.rs | 8 |
1 files changed, 6 insertions, 2 deletions
diff --git a/src/format/msgpack.rs b/src/format/msgpack.rs index d823a6d..09bd2bb 100644 --- a/src/format/msgpack.rs +++ b/src/format/msgpack.rs @@ -33,8 +33,12 @@ pub struct Iter<'a, R: 'a> where R: BufRead { impl<'a, R: 'a> Iterator for Iter<'a, R> where R: BufRead { type Item = ::Result<Event<'a>>; fn next(&mut self) -> Option<::Result<Event<'a>>> { - Some(Decodable::decode(&mut Decoder::new(&mut self.input)) - .map_err(|e| ::IlcError::MsgpackDecode(e))) + use msgpack::decode; + match Event::decode(&mut Decoder::new(&mut self.input)) { + Ok(e) => Some(Ok(e)), + Err(decode::serialize::Error::InvalidMarkerRead(decode::ReadError::UnexpectedEOF)) => None, + Err(e) => Some(Err(::IlcError::MsgpackDecode(e))) + } } } |