1use thiserror::Error;
2
3use spatialrust_core::SpatialError;
4
5#[derive(Debug, Error, PartialEq)]
7pub enum IoError {
8 #[error("io failure: {0}")]
10 Io(String),
11
12 #[error("pcd parse error: {0}")]
14 PcdParse(String),
15
16 #[error("pcd format error: {0}")]
18 PcdFormat(String),
19
20 #[error("ply parse error: {0}")]
22 PlyParse(String),
23
24 #[error("ply format error: {0}")]
26 PlyFormat(String),
27
28 #[error("las parse error: {0}")]
30 LasParse(String),
31
32 #[error("las format error: {0}")]
34 LasFormat(String),
35
36 #[error("laz format error: {0}")]
38 LazFormat(String),
39
40 #[error("e57 parse error: {0}")]
42 E57Parse(String),
43
44 #[error("e57 format error: {0}")]
46 E57Format(String),
47
48 #[error("copc parse error: {0}")]
50 CopcParse(String),
51
52 #[error("copc format error: {0}")]
54 CopcFormat(String),
55
56 #[error(transparent)]
58 Core(#[from] SpatialError),
59}
60
61impl From<std::io::Error> for IoError {
62 fn from(error: std::io::Error) -> Self {
63 Self::Io(error.to_string())
64 }
65}
66
67#[cfg_attr(not(feature = "io-pcd"), allow(dead_code))]
68pub(crate) fn pcd_parse(message: impl Into<String>) -> IoError {
69 IoError::PcdParse(message.into())
70}
71
72#[cfg_attr(not(feature = "io-pcd"), allow(dead_code))]
73pub(crate) fn pcd_format(message: impl Into<String>) -> IoError {
74 IoError::PcdFormat(message.into())
75}
76
77#[cfg_attr(not(feature = "io-ply"), allow(dead_code))]
78pub(crate) fn ply_parse(message: impl Into<String>) -> IoError {
79 IoError::PlyParse(message.into())
80}
81
82#[cfg_attr(not(feature = "io-ply"), allow(dead_code))]
83pub(crate) fn ply_format(message: impl Into<String>) -> IoError {
84 IoError::PlyFormat(message.into())
85}
86
87#[cfg_attr(not(feature = "io-las"), allow(dead_code))]
88pub(crate) fn las_parse(message: impl Into<String>) -> IoError {
89 IoError::LasParse(message.into())
90}
91
92#[cfg_attr(not(feature = "io-las"), allow(dead_code))]
93pub(crate) fn las_format(message: impl Into<String>) -> IoError {
94 IoError::LasFormat(message.into())
95}
96
97#[allow(dead_code)]
98pub(crate) fn laz_format(message: impl Into<String>) -> IoError {
99 IoError::LazFormat(message.into())
100}
101
102#[cfg_attr(not(feature = "io-e57"), allow(dead_code))]
103pub(crate) fn e57_parse(message: impl Into<String>) -> IoError {
104 IoError::E57Parse(message.into())
105}
106
107#[cfg_attr(not(feature = "io-e57"), allow(dead_code))]
108pub(crate) fn e57_format(message: impl Into<String>) -> IoError {
109 IoError::E57Format(message.into())
110}
111
112#[cfg_attr(not(feature = "io-copc"), allow(dead_code))]
113pub(crate) fn copc_parse(message: impl Into<String>) -> IoError {
114 IoError::CopcParse(message.into())
115}
116
117#[cfg_attr(not(feature = "io-copc"), allow(dead_code))]
118pub(crate) fn copc_format(message: impl Into<String>) -> IoError {
119 IoError::CopcFormat(message.into())
120}