use validation::{Error, Validate};
use {buffer, extensions, Extras, Index, Root, Path};
pub const VALID_MIME_TYPES: &'static [&'static str] = &[
"image/jpeg",
"image/png",
];
#[derive(Clone, Debug, Deserialize, Validate)]
pub struct Image {
#[serde(rename = "bufferView")]
pub buffer_view: Option<Index<buffer::View>>,
#[serde(rename = "mimeType")]
pub mime_type: Option<MimeType>,
#[cfg(feature = "names")]
pub name: Option<String>,
pub uri: Option<String>,
#[serde(default)]
pub extensions: extensions::image::Image,
#[serde(default)]
pub extras: Extras,
}
#[derive(Clone, Debug, Deserialize)]
pub struct MimeType(pub String);
impl Validate for MimeType {
fn validate_completely<P, R>(&self, _: &Root, path: P, report: &mut R)
where P: Fn() -> Path, R: FnMut(&Fn() -> Path, Error)
{
if !VALID_MIME_TYPES.contains(&self.0.as_str()) {
report(&path, Error::Invalid);
}
}
}