craftflow_nbt/
error.rs

1use thiserror::Error;
2
3/// The result type used in this crate
4pub type Result<T> = std::result::Result<T, Error>;
5
6/// The error type used in this crate.
7///
8/// Either IO Error or invalid data
9#[derive(Error, Debug)]
10pub enum Error {
11	#[error("IO error: {0}")]
12	IOError(#[from] std::io::Error),
13	#[error("Invalid data: {0}")]
14	InvalidData(String),
15}
16
17impl serde::ser::Error for Error {
18	fn custom<T: std::fmt::Display>(msg: T) -> Self {
19		Error::InvalidData(msg.to_string())
20	}
21}
22
23impl serde::de::Error for Error {
24	fn custom<T: std::fmt::Display>(msg: T) -> Self {
25		Error::InvalidData(msg.to_string())
26	}
27}