use super::stream::*;
use std::{fs::*, io, path::*};
pub enum ImageSource {
Owned(Vec<u8>, bool),
LocalFile(PathBuf, bool),
Stream(ImageStreamRef),
}
impl ImageSource {
pub fn into_owned(&mut self) -> io::Result<()> {
match self {
Self::LocalFile(path, compressed) => *self = Self::Owned(read(path)?, *compressed),
Self::Stream(stream) => {
let (mut reader, compressed) = stream.open()?;
let mut data = Vec::default();
reader.read_to_end(&mut data)?;
*self = Self::Owned(data, compressed);
}
_ => {}
}
Ok(())
}
}