TextureSync/server/texture-sync-server/src/model/mod.rs

46 lines
957 B
Rust
Raw Normal View History

2019-04-20 01:24:19 +02:00
// TODO: remove on implementation
#![allow(unused_imports)]
#![allow(unused_variables)]
#![allow(dead_code)]
2019-05-03 11:19:34 +02:00
use std::io;
mod sha256;
pub use sha256::Sha256;
2019-04-20 01:24:19 +02:00
mod texture_format;
pub use texture_format::TextureFormat;
2019-05-05 19:16:52 +02:00
#[derive(Eq, PartialEq, Clone, Serialize, Deserialize, Debug, Hash)]
2019-04-20 01:24:19 +02:00
pub struct Texture {
pub id: String,
pub name: String,
pub tags: Vec<String>,
pub format: TextureFormat,
pub resolution: (usize, usize),
pub texture_hash: Sha256,
}
2019-05-03 11:19:34 +02:00
pub enum ReplaceTextureStatus {
/// Done.
2019-05-03 11:19:34 +02:00
Ok,
/// Call Again With Texture Binary
2019-05-03 11:19:34 +02:00
NeedTextureData(Sha256),
}
pub type ProtocolResult<T> = Result<T, ProtocolError>;
pub enum ProtocolError {
BadRequest(String),
FileNotFound(String),
Conflict(String),
InternalServerError(std::io::Error),
NotImplemented,
}
2019-05-03 11:19:34 +02:00
impl From<io::Error> for ProtocolError {
fn from(err: io::Error) -> Self {
ProtocolError::InternalServerError(err)
}
2019-05-03 11:19:34 +02:00
}