From 4a30d7f776fe9901dfaad4df39136d87b3a15858 Mon Sep 17 00:00:00 2001 From: David Harvey-Macaulay Date: Wed, 24 Jul 2019 18:15:59 +0100 Subject: [PATCH] Fix compiler warnings --- gltf-json/src/buffer.rs | 4 ++-- gltf-json/src/extensions/material.rs | 4 ++-- gltf-json/src/extensions/root.rs | 4 +--- gltf-json/src/extensions/scene.rs | 2 +- gltf-json/src/extras.rs | 4 ---- gltf-json/src/image.rs | 4 ++-- gltf-json/src/material.rs | 4 ++-- gltf-json/src/scene.rs | 4 ++-- src/lib.rs | 17 ++++++++++++++++- 9 files changed, 28 insertions(+), 19 deletions(-) diff --git a/gltf-json/src/buffer.rs b/gltf-json/src/buffer.rs index 33caa8ce..98d1a78f 100644 --- a/gltf-json/src/buffer.rs +++ b/gltf-json/src/buffer.rs @@ -2,8 +2,8 @@ use gltf_derive::Validate; use serde_derive::{Serialize, Deserialize}; use serde::{de, ser}; use std::fmt; -use crate::validation::{Checked, Error, Validate}; -use crate::{extensions, Extras, Index, Root, Path}; +use crate::validation::Checked; +use crate::{extensions, Extras, Index}; /// Corresponds to `GL_ARRAY_BUFFER`. pub const ARRAY_BUFFER: u32 = 34_962; diff --git a/gltf-json/src/extensions/material.rs b/gltf-json/src/extensions/material.rs index 016a3d55..75051ea0 100644 --- a/gltf-json/src/extensions/material.rs +++ b/gltf-json/src/extensions/material.rs @@ -1,7 +1,7 @@ use gltf_derive::Validate; use serde_derive::{Serialize, Deserialize}; -use crate::{Extras, Path, Root, texture, validation::Error, -validation::Validate, material::StrengthFactor}; +#[cfg(feature = "KHR_materials_pbrSpecularGlossiness")] +use crate::{Extras, texture, validation::Validate, material::StrengthFactor}; /// The material appearance of a primitive. #[derive(Clone, Debug, Default, Deserialize, Serialize, Validate)] diff --git a/gltf-json/src/extensions/root.rs b/gltf-json/src/extensions/root.rs index a5f7b4c7..27df08d9 100644 --- a/gltf-json/src/extensions/root.rs +++ b/gltf-json/src/extensions/root.rs @@ -1,8 +1,6 @@ use gltf_derive::Validate; use serde_derive::{Serialize, Deserialize}; -use crate::Index; - /// The root object of a glTF 2.0 asset. #[derive(Clone, Debug, Default, Deserialize, Serialize, Validate)] pub struct Root { @@ -20,7 +18,7 @@ pub struct KhrLightsPunctual { #[cfg(feature = "KHR_lights_punctual")] impl crate::root::Get for crate::Root { - fn get(&self, id: Index) + fn get(&self, id: crate::Index) -> Option<&crate::extensions::scene::khr_lights_punctual::Light> { if let Some(extensions) = self.extensions.as_ref() { diff --git a/gltf-json/src/extensions/scene.rs b/gltf-json/src/extensions/scene.rs index 25e0bc9e..92215250 100644 --- a/gltf-json/src/extensions/scene.rs +++ b/gltf-json/src/extensions/scene.rs @@ -111,7 +111,7 @@ pub mod khr_lights_punctual { impl Validate for Light { fn validate(&self, root: &Root, path: P, report: &mut R) - where P: Fn() -> Path, R: FnMut(&Fn() -> Path, Error) + where P: Fn() -> Path, R: FnMut(&dyn Fn() -> Path, Error) { if let Checked::Valid(ty) = self.type_.as_ref() { if *ty == Type::Spot && self.spot.is_none() { diff --git a/gltf-json/src/extras.rs b/gltf-json/src/extras.rs index 514214bd..eab20b26 100644 --- a/gltf-json/src/extras.rs +++ b/gltf-json/src/extras.rs @@ -2,12 +2,8 @@ use gltf_derive::Validate; use serde_derive::{Serialize, Deserialize}; use std::fmt; -#[cfg(feature = "extras")] -use crate::{Path, Root}; #[cfg(feature = "extras")] pub use serde_json::value::RawValue; -#[cfg(feature = "extras")] -use crate::validation::{Error, Validate}; /// Data type of the `extras` attribute on all glTF objects. #[cfg(feature = "extras")] diff --git a/gltf-json/src/image.rs b/gltf-json/src/image.rs index 9a145c46..dfa2b73b 100644 --- a/gltf-json/src/image.rs +++ b/gltf-json/src/image.rs @@ -1,7 +1,7 @@ use gltf_derive::Validate; use serde_derive::{Serialize, Deserialize}; -use crate::validation::{Error, Validate}; -use crate::{buffer, extensions, Extras, Index, Root, Path}; +use crate::validation::Validate; +use crate::{buffer, extensions, Extras, Index}; /// All valid MIME types. pub const VALID_MIME_TYPES: &'static [&'static str] = &[ diff --git a/gltf-json/src/material.rs b/gltf-json/src/material.rs index ddfe6235..438eaf76 100644 --- a/gltf-json/src/material.rs +++ b/gltf-json/src/material.rs @@ -2,8 +2,8 @@ use gltf_derive::Validate; use serde_derive::{Serialize, Deserialize}; use serde::{de, ser}; use std::fmt; -use crate::validation::{Checked, Error, Validate}; -use crate::{extensions, texture, Extras, Index, Root, Path}; +use crate::validation::{Checked, Validate}; +use crate::{extensions, texture, Extras, Index}; /// All valid alpha modes. pub const VALID_ALPHA_MODES: &'static [&'static str] = &[ diff --git a/gltf-json/src/scene.rs b/gltf-json/src/scene.rs index 0917dbee..bbae30bc 100644 --- a/gltf-json/src/scene.rs +++ b/gltf-json/src/scene.rs @@ -1,7 +1,7 @@ use gltf_derive::Validate; use serde_derive::{Serialize, Deserialize}; -use crate::validation::{Error, Validate}; -use crate::{camera, extensions, mesh, scene, skin, Extras, Index, Root, Path}; +use crate::validation::Validate; +use crate::{camera, extensions, mesh, scene, skin, Extras, Index}; /// A node in the node hierarchy. When the node contains `skin`, all /// `mesh.primitives` must contain `JOINTS_0` and `WEIGHTS_0` attributes. diff --git a/src/lib.rs b/src/lib.rs index e9c45af9..a10edc9f 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -497,10 +497,26 @@ impl std::fmt::Display for Error { #[cfg(feature = "import")] Error::Base64(ref e) => e.fmt(f), Error::Binary(ref e) => e.fmt(f), + #[cfg(feature = "import")] + Error::BufferLength { buffer, expected, actual } => { + write!( + f, + "buffer {}: expected {} bytes but received {} bytes", + buffer, + expected, + actual + ) + }, Error::Deserialize(ref e) => e.fmt(f), Error::Io(ref e) => e.fmt(f), #[cfg(feature = "import")] Error::Image(ref e) => e.fmt(f), + #[cfg(feature = "import")] + Error::MissingBlob => write!(f, "missing binary portion of binary glTF"), + #[cfg(feature = "import")] + Error::UnsupportedImageEncoding => write!(f, "unsupported image encoding"), + #[cfg(feature = "import")] + Error::UnsupportedScheme => write!(f, "unsupported URI scheme"), Error::Validation(ref xs) => { write!(f, "invalid glTF:")?; for &(ref path, ref error) in xs { @@ -508,7 +524,6 @@ impl std::fmt::Display for Error { } Ok(()) } - _ => f.write_str(std::error::Error::description(self)) } } }