aboutsummaryrefslogtreecommitdiff
path: root/src/format/binary.rs
diff options
context:
space:
mode:
Diffstat (limited to 'src/format/binary.rs')
-rw-r--r--src/format/binary.rs22
1 files changed, 10 insertions, 12 deletions
diff --git a/src/format/binary.rs b/src/format/binary.rs
index 367cdf9..a7ae7ca 100644
--- a/src/format/binary.rs
+++ b/src/format/binary.rs
@@ -14,7 +14,6 @@
use std::io::{ BufRead, Write };
use std::iter::Iterator;
-use std::marker::PhantomData;
use event::Event;
use context::Context;
@@ -24,29 +23,28 @@ use bincode::{ self, SizeLimit };
pub struct Binary;
-pub struct Iter<'a, R: 'a> where R: BufRead {
- _phantom: PhantomData<&'a ()>,
- input: R
+pub struct Iter<'a> {
+ input: &'a mut BufRead
}
-impl<'a, R: 'a> Iterator for Iter<'a, R> where R: BufRead {
+impl<'a> Iterator for Iter<'a> {
type Item = ::Result<Event<'a>>;
fn next(&mut self) -> Option<::Result<Event<'a>>> {
- Some(bincode::rustc_serialize::decode_from::<R, Event>(&mut self.input, SizeLimit::Infinite)
+ Some(bincode::rustc_serialize::decode_from::<_, Event>(&mut self.input, SizeLimit::Infinite)
.map_err(|_| ::IlcError::BincodeDecode))
}
}
-impl<'a, W> Encode<'a, W> for Binary where W: Write {
- fn encode(&'a self, _context: &'a Context, mut output: W, event: &'a Event) -> ::Result<()> {
+impl Encode for Binary {
+ fn encode<'a>(&'a self, _context: &'a Context, mut output: &'a mut Write, event: &'a Event) -> ::Result<()> {
bincode::rustc_serialize::encode_into(event, &mut output, SizeLimit::Infinite)
.map_err(|_| ::IlcError::BincodeEncode)
}
}
-impl<'a, R: 'a> Decode<'a, R> for Binary where R: BufRead {
- type Output = Iter<'a, R>;
- fn decode(&'a mut self, _context: &'a Context, input: R) -> Iter<R> {
- Iter { _phantom: PhantomData, input: input }
+impl Decode for Binary {
+ fn decode<'a>(&'a mut self, _context: &'a Context, input: &'a mut BufRead)
+ -> Box<Iterator<Item = ::Result<Event<'a>>> + 'a> {
+ Box::new(Iter { input: input })
}
}