SeekError,
}
-type ByteIOResult<T> = Result<T, ByteIOError>;
+pub type ByteIOResult<T> = Result<T, ByteIOError>;
pub trait ByteIO {
fn read_buf(&mut self, buf: &mut [u8]) -> ByteIOResult<usize>;
macro_rules! read_int {
($s: ident, $inttype: ty, $size: expr, $which: ident) => ({
let mut buf = [0; $size];
- try!($s.read_buf(&mut buf));
+ $s.read_buf(&mut buf)?;
unsafe {
Ok((*(buf.as_ptr() as *const $inttype)).$which())
}
macro_rules! peek_int {
($s: ident, $inttype: ty, $size: expr, $which: ident) => ({
let mut buf = [0; $size];
- try!($s.peek_buf(&mut buf));
+ $s.peek_buf(&mut buf)?;
unsafe {
Ok((*(buf.as_ptr() as *const $inttype)).$which())
}
} else {
let mut ssize = len;
let mut buf : [u8; 16] = [0; 16];
- let mut bref = &mut buf;
+ let bref = &mut buf;
while ssize > bref.len() {
self.io.read_buf(bref)?;
ssize -= bref.len();
pos: usize,
}
-pub struct FileWriter<'a> {
- file: &'a File,
+pub struct FileWriter {
+ file: File,
}
impl<'a> ByteWriter<'a> {
}
}
-impl<'a> FileWriter<'a> {
- pub fn new_write(file: &'a mut File) -> Self {
+impl FileWriter {
+ pub fn new_write(file: File) -> Self {
FileWriter { file: file }
}
}
-impl<'a> ByteIO for FileWriter<'a> {
+impl ByteIO for FileWriter {
#[allow(unused_variables)]
fn read_byte(&mut self) -> ByteIOResult<u8> {
Err(ByteIOError::NotImplemented)