fn is_seekable(&mut self) -> bool;
/// Returns stream size or -1 if it is not known.
fn size(&mut self) -> i64;
+ /// Flushes output if possible.
+ fn flush(&mut self) -> ByteIOResult<()>;
}
/// High-level bytestream reader.
fn size(&mut self) -> i64 {
self.buf.len() as i64
}
+
+ fn flush(&mut self) -> ByteIOResult<()> { Ok(()) }
}
impl<T: Read+Seek> FileReader<T> {
fn size(&mut self) -> i64 {
-1
}
+
+ fn flush(&mut self) -> ByteIOResult<()> { Ok(()) }
}
/// High-level bytestream writer.
if sz == -1 { return -1; }
sz - (self.tell() as i64)
}
+
+ /// Flushes output stream if possible.
+ pub fn flush(&mut self) -> ByteIOResult<()> {
+ self.io.flush()
+ }
}
impl<'a> MemoryWriter<'a> {
fn size(&mut self) -> i64 {
self.buf.len() as i64
}
+
+ fn flush(&mut self) -> ByteIOResult<()> { Ok(()) }
}
impl<'a> GrowableMemoryWriter<'a> {
fn size(&mut self) -> i64 {
self.buf.len() as i64
}
+
+ fn flush(&mut self) -> ByteIOResult<()> { Ok(()) }
}
impl<T: Write+Seek> FileWriter<T> {
fn size(&mut self) -> i64 {
-1
}
+
+ fn flush(&mut self) -> ByteIOResult<()> {
+ match self.file.flush() {
+ Ok(()) => Ok(()),
+ Err(_) => Err(ByteIOError::WriteError),
+ }
+ }
}
#[cfg(test)]