1use std::{error, fmt};
4
5use fbxcel::{low::FbxVersion, tree};
6
7pub type Result<T> = std::result::Result<T, Error>;
9
10#[derive(Debug)]
12#[non_exhaustive]
13pub enum Error {
14 UnsupportedVersion(FbxVersion),
19 Tree(tree::any::Error),
21 Dom(Box<dyn error::Error + Send + Sync + 'static>),
23}
24
25impl error::Error for Error {
26 fn source(&self) -> Option<&(dyn error::Error + 'static)> {
27 match self {
28 Error::Tree(e) => Some(e),
29 Error::Dom(e) => Some(&**e),
30 Error::UnsupportedVersion(..) => None,
31 }
32 }
33}
34
35impl fmt::Display for Error {
36 fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
37 match self {
38 Error::Tree(e) => write!(f, "Tree load error: {}", e),
39 Error::Dom(e) => write!(f, "DOM document load error: {}", e),
40 Error::UnsupportedVersion(ver) => write!(f, "Unsupported FBX version: {:?}", ver),
41 }
42 }
43}
44
45impl From<tree::any::Error> for Error {
46 fn from(e: tree::any::Error) -> Self {
47 Error::Tree(e)
48 }
49}
50
51impl From<crate::v7400::LoadError> for Error {
52 fn from(e: crate::v7400::LoadError) -> Self {
53 Error::Dom(e.into())
54 }
55}