use std::path::{Path, PathBuf};
use url::Url;
use document::Document;
#[derive(Clone, Debug, Eq, Ord, PartialEq, PartialOrd, Hash)]
pub struct SimpleDocument {
bytes: Option<Vec<u8>>,
path: PathBuf,
url: Url,
wkhtmltopdf: bool,
}
impl SimpleDocument {
pub fn new(path: PathBuf, url: Url, wkhtmltopdf: bool) -> Self {
SimpleDocument {
bytes: None,
path,
url,
wkhtmltopdf,
}
}
pub fn bytes(&self) -> Option<&[u8]> {
self.bytes.as_ref().map(|v| &v[..])
}
}
impl Document for SimpleDocument {
fn path(&self) -> &Path {
&self.path
}
fn url(&self) -> &Url {
&self.url
}
fn wkhtmltopdf(&self) -> bool {
self.wkhtmltopdf
}
fn set_bytes(&mut self, bytes: Option<Vec<u8>>) {
self.bytes = bytes
}
}