use serde::Serialize; use std::io; mod sha256; pub use sha256::Sha256; mod date; pub use date::Date; mod texture_format; pub use texture_format::TextureFormat; #[derive(Eq, PartialEq, Clone, Serialize, Deserialize, Debug, Hash)] pub struct Texture { pub id: String, pub name: String, pub tags: Vec, pub format: TextureFormat, pub added_on: Date, pub resolution: (u64, u64), pub texture_hash: Sha256, } pub enum ReplaceTextureStatus { /// Done. Ok, /// Call Again With Texture Binary NeedTextureData(Sha256), } pub type ProtocolResult = Result; pub enum ProtocolError { BadRequest(String), FileNotFound(String), Conflict(String), InternalServerError(std::io::Error), NotImplemented, } impl From for ProtocolError { fn from(err: io::Error) -> Self { if err.kind() == io::ErrorKind::NotFound { ProtocolError::FileNotFound("File Not Found!".to_string()) } else { ProtocolError::InternalServerError(err) } } }