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
pub mod biome;
pub mod tex;
mod bits;
mod dimension;
mod files;
mod java;
mod region;
mod render;
mod rendered_palette;
pub use bits::*;
pub use dimension::*;
pub use files::*;
pub use java::*;
pub use region::*;
pub use render::*;
pub use rendered_palette::*;
#[cfg(test)]
mod test;
#[derive(Debug)]
pub enum Error {
IO(std::io::Error),
InvalidOffset(isize, isize),
UnknownCompression(u8),
ChunkTooLarge,
}
impl From<std::io::Error> for Error {
fn from(err: std::io::Error) -> Error {
Error::IO(err)
}
}
pub type Result<T> = std::result::Result<T, Error>;
impl std::fmt::Display for Error {
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
match self {
Error::IO(e) => f.write_fmt(format_args!("io error: {e:?}")),
Error::InvalidOffset(x, z) => {
f.write_fmt(format_args!("invalid offset: x = {x}, z = {z}"))
}
Error::UnknownCompression(scheme) => f.write_fmt(format_args!(
"compression scheme ({scheme}) was not recognised for chunk"
)),
Error::ChunkTooLarge => f.write_str("chunk too large to store"),
}
}
}
impl std::error::Error for Error {}