Skip to content

Commit

Permalink
Merge pull request #239 from alteous/fix-warnings
Browse files Browse the repository at this point in the history
Fix compiler warnings
  • Loading branch information
alteous authored Jul 27, 2019
2 parents edb73e8 + 4a30d7f commit b9a36ba
Show file tree
Hide file tree
Showing 9 changed files with 28 additions and 19 deletions.
4 changes: 2 additions & 2 deletions gltf-json/src/buffer.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
4 changes: 2 additions & 2 deletions gltf-json/src/extensions/material.rs
Original file line number Diff line number Diff line change
@@ -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)]
Expand Down
4 changes: 1 addition & 3 deletions gltf-json/src/extensions/root.rs
Original file line number Diff line number Diff line change
@@ -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 {
Expand All @@ -20,7 +18,7 @@ pub struct KhrLightsPunctual {

#[cfg(feature = "KHR_lights_punctual")]
impl crate::root::Get<crate::extensions::scene::khr_lights_punctual::Light> for crate::Root {
fn get(&self, id: Index<crate::extensions::scene::khr_lights_punctual::Light>)
fn get(&self, id: crate::Index<crate::extensions::scene::khr_lights_punctual::Light>)
-> Option<&crate::extensions::scene::khr_lights_punctual::Light>
{
if let Some(extensions) = self.extensions.as_ref() {
Expand Down
2 changes: 1 addition & 1 deletion gltf-json/src/extensions/scene.rs
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,7 @@ pub mod khr_lights_punctual {

impl Validate for Light {
fn validate<P, R>(&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() {
Expand Down
4 changes: 0 additions & 4 deletions gltf-json/src/extras.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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")]
Expand Down
4 changes: 2 additions & 2 deletions gltf-json/src/image.rs
Original file line number Diff line number Diff line change
@@ -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] = &[
Expand Down
4 changes: 2 additions & 2 deletions gltf-json/src/material.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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] = &[
Expand Down
4 changes: 2 additions & 2 deletions gltf-json/src/scene.rs
Original file line number Diff line number Diff line change
@@ -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.
Expand Down
17 changes: 16 additions & 1 deletion src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -497,18 +497,33 @@ 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 {
write!(f, " {}: {};", path, error)?;
}
Ok(())
}
_ => f.write_str(std::error::Error::description(self))
}
}
}
Expand Down

0 comments on commit b9a36ba

Please sign in to comment.