2020-12-05 09:54:38 +00:00
|
|
|
use std::io::Read;
|
|
|
|
|
|
|
|
/// Read trait for tape devices
|
|
|
|
///
|
|
|
|
/// Normal Read, but allows to query additional status flags.
|
|
|
|
pub trait TapeRead: Read {
|
|
|
|
/// Return true if there is an "INCOMPLETE" mark at EOF
|
|
|
|
///
|
|
|
|
/// Raises an error if you query this flag before reaching EOF.
|
|
|
|
fn is_incomplete(&self) -> Result<bool, std::io::Error>;
|
|
|
|
|
|
|
|
/// Return true if there is a file end marker before EOF
|
|
|
|
///
|
|
|
|
/// Raises an error if you query this flag before reaching EOF.
|
|
|
|
fn has_end_marker(&self) -> Result<bool, std::io::Error>;
|
|
|
|
}
|
|
|
|
|
2021-03-29 08:09:49 +00:00
|
|
|
pub enum BlockReadStatus {
|
|
|
|
Ok(usize),
|
|
|
|
EndOfFile,
|
|
|
|
EndOfStream,
|
|
|
|
}
|
2020-12-05 09:54:38 +00:00
|
|
|
|
2021-03-29 08:09:49 +00:00
|
|
|
/// Read streams of blocks
|
|
|
|
pub trait BlockRead {
|
|
|
|
/// Read the next block (whole buffer)
|
|
|
|
fn read_block(&mut self, buffer: &mut [u8]) -> Result<BlockReadStatus, std::io::Error>;
|
2020-12-05 09:54:38 +00:00
|
|
|
}
|