1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83

//!
//! Contain a [loader](crate::Loader) for loading any type of asset runtime on both desktop and web
//! and a [saver](crate::Saver) for saving (available on desktop only).
//!

#[doc(hidden)]
pub mod loader;
#[doc(inline)]
pub use loader::*;

#[doc(hidden)]
#[cfg(not(target_arch = "wasm32"))]
pub mod saver;
#[doc(inline)]
#[cfg(not(target_arch = "wasm32"))]
pub use saver::*;

#[doc(hidden)]
#[cfg(feature = "image-io")]
pub mod texture;
#[doc(inline)]
#[cfg(feature = "image-io")]
pub use texture::*;

#[doc(hidden)]
#[cfg(feature = "3d-io")]
pub mod threed;
#[doc(inline)]
#[cfg(feature = "3d-io")]
pub use threed::*;

#[doc(hidden)]
#[cfg(feature = "obj-io")]
pub mod obj;
#[doc(inline)]
#[cfg(feature = "obj-io")]
pub use obj::*;

///
/// Error message from the [core](crate::io) module.
///
#[derive(Debug)]
pub enum IOError {
    #[cfg(feature = "image-io")]
    Image(image::ImageError),
    #[cfg(feature = "3d-io")]
    Bincode(bincode::Error),
    #[cfg(feature = "obj-io")]
    Obj(wavefront_obj::ParseError),
    #[cfg(not(target_arch = "wasm32"))]
    IO(std::io::Error),
    FailedToLoad {message: String},
    FailedToSave {message: String}
}

#[cfg(feature = "image-io")]
impl From<image::ImageError> for IOError {
    fn from(other: image::ImageError) -> Self {
        IOError::Image(other)
    }
}

#[cfg(feature = "3d-io")]
impl From<bincode::Error> for IOError {
    fn from(other: bincode::Error) -> Self {
        IOError::Bincode(other)
    }
}

#[cfg(feature = "obj-io")]
impl From<wavefront_obj::ParseError> for IOError {
    fn from(other: wavefront_obj::ParseError) -> Self {
        IOError::Obj(other)
    }
}

#[cfg(not(target_arch = "wasm32"))]
impl From<std::io::Error> for IOError {
    fn from(other: std::io::Error) -> Self {
        IOError::IO(other)
    }
}