use std::fmt;
use std::io;
pub struct LiteralSource {
pub data: Box<dyn io::Read>,
pub len: u64,
pub binary: bool,
}
impl Clone for LiteralSource {
fn clone(&self) -> Self {
panic!("LiteralSource::clone")
}
}
impl PartialEq for LiteralSource {
fn eq(&self, other: &Self) -> bool {
self.len == other.len && self.binary == other.binary
}
}
impl Eq for LiteralSource {}
impl fmt::Debug for LiteralSource {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
f.debug_struct("LiteralSource")
.field("data", &"<data>")
.field("len", &self.len)
.field("binary", &self.binary)
.finish()
}
}
impl LiteralSource {
#[cfg(test)]
pub fn of_data(data: &'static [u8], binary: bool) -> Self {
LiteralSource {
data: Box::new(data),
len: data.len() as u64,
binary,
}
}
pub fn of_reader(
reader: impl io::Read + 'static,
len: u64,
binary: bool,
) -> Self {
LiteralSource {
data: Box::new(reader),
len,
binary,
}
}
}