use bytes::Bytes;
use super::ImageAsset;
use crate::geometry::Size;
#[derive(Clone, PartialEq)]
pub enum ImageSource {
Placeholder(Size<f32>),
Asset(ImageAsset),
Bytes(Bytes),
}
impl ImageSource {
pub fn placeholder(width: f32, height: f32) -> ImageSource {
ImageSource::Placeholder(Size::new(width, height))
}
}
impl Default for ImageSource {
fn default() -> Self {
ImageSource::Placeholder(Size::default())
}
}
impl From<ImageAsset> for ImageSource {
fn from(asset: ImageAsset) -> Self {
ImageSource::Asset(asset)
}
}
impl From<Bytes> for ImageSource {
fn from(bytes: Bytes) -> Self {
ImageSource::Bytes(bytes)
}
}
impl From<&'static [u8]> for ImageSource {
fn from(bytes: &'static [u8]) -> Self {
ImageSource::Bytes(Bytes::from_static(bytes))
}
}