use std::fmt::{Display, Formatter, Result};
use crate::Bytes;
use serde::{Deserialize, Serialize};
#[derive(Serialize, Deserialize, Debug)]
pub enum ImageType {
Png,
Gif,
Unkown,
}
#[derive(Serialize, Deserialize, Debug)]
pub struct ImageResponse {
pub bytes: Bytes,
pub format: ImageType,
pub size: u64,
pub process_time: f32,
}
impl Display for ImageResponse {
fn fmt(&self, f: &mut Formatter<'_>) -> Result {
let fs = match self.format {
ImageType::Png => "png",
ImageType::Gif => "gif",
ImageType::Unkown => "error",
};
write!(f, "<Image format={} size={}>", fs, self.size)
}
}
impl Display for ImageType {
fn fmt(&self, f: &mut Formatter) -> Result {
write!(f, "{:?}", self)
}
}