#[macro_use]
pub mod macros;
#[cfg(test)]
mod test;
use std::fmt;
pub struct ByteStream<'a> {
pub byte: u8,
pub mark_index: usize,
pub stream: &'a [u8],
pub stream_index: usize
}
impl<'a> ByteStream<'a> {
pub fn new(stream: &'a [u8]) -> ByteStream<'a> {
ByteStream{ byte: 0,
mark_index: 0,
stream: stream,
stream_index: 0 }
}
}
impl<'a> fmt::Debug for ByteStream<'a> {
fn fmt(&self, formatter: &mut fmt::Formatter) -> fmt::Result {
if is_visible_8bit!(self.byte) || self.byte == 0x20 || self.byte == 0xFF {
write!(formatter, "ByteStream(byte[{}]='{}', mark_index={}, stream_index={})",
self.byte, self.byte as char, self.mark_index, self.stream_index)
} else {
write!(formatter, "ByteStream(byte[{}]='', mark_index={}, stream_index={})",
self.byte, self.mark_index, self.stream_index)
}
}
}
impl<'a> fmt::Display for ByteStream<'a> {
fn fmt(&self, formatter: &mut fmt::Formatter) -> fmt::Result {
if is_visible_8bit!(self.byte) || self.byte == 0x20 || self.byte == 0xFF {
write!(formatter, "byte[{}]='{}', mark_index={}, stream_index={}",
self.byte, self.byte as char, self.mark_index, self.stream_index)
} else {
write!(formatter, "byte[{}]='', mark_index={}, stream_index={}",
self.byte, self.mark_index, self.stream_index)
}
}
}