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
use crate::las::laszip::{CompressorType, LazItemType};
use std::fmt;
#[derive(Debug)]
#[non_exhaustive]
pub enum LasZipError {
UnknownLazItem(u16),
UnsupportedLazItemVersion(LazItemType, u16),
UnknownCompressorType(u16),
UnsupportedCompressorType(CompressorType),
UnsupportedPointFormat(u8),
IoError(std::io::Error),
BufferLenNotMultipleOfPointSize {
buffer_len: usize,
point_size: usize,
},
MissingChunkTable,
}
impl From<std::io::Error> for LasZipError {
fn from(e: std::io::Error) -> Self {
LasZipError::IoError(e)
}
}
impl fmt::Display for LasZipError {
fn fmt(&self, f: &mut fmt::Formatter) -> Result<(), fmt::Error> {
match self {
LasZipError::UnknownLazItem(t) => write!(f, "Item with type code: {} is unknown", t),
LasZipError::UnsupportedLazItemVersion(item_type, version) => write!(
f,
"Item {:?} with compression version: {} is not supported",
item_type, version
),
LasZipError::UnknownCompressorType(compressor_type) => {
write!(f, "Compressor type {} is not valid", compressor_type)
}
LasZipError::UnsupportedCompressorType(compressor_type) => {
write!(f, "Compressor type {:?} is not supported", compressor_type)
}
LasZipError::IoError(e) => write!(f, "IoError: {}", e),
LasZipError::BufferLenNotMultipleOfPointSize {
buffer_len: bl,
point_size: ps,
} => write!(
f,
"The len of the buffer ({}) is not a multiple of the point size {}",
bl, ps
),
LasZipError::UnsupportedPointFormat(id) => {
write!(f, "Point format {} is not supported", id)
}
LasZipError::MissingChunkTable => write!(f, "The chunk table could not be found"),
}
}
}