-
Notifications
You must be signed in to change notification settings - Fork 11
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Refactoring with API improvements (#8)
- Loading branch information
1 parent
5e892d2
commit 1e56293
Showing
7 changed files
with
880 additions
and
859 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -15,6 +15,3 @@ byteorder = "1.3" | |
named-binary-tag = "0.3" | ||
bitvec = "0.17" | ||
log = "0.4.11" | ||
|
||
[dev-dependencies] | ||
tempfile = "3.1" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,72 @@ | ||
use nbt::decode::TagDecodeError; | ||
use std::io; | ||
|
||
/// Possible errors while loading the chunk. | ||
#[derive(Debug)] | ||
pub enum ChunkReadError { | ||
/// Chunk at specified coordinates inside region not found. | ||
ChunkNotFound { | ||
region_chunk_x: u8, | ||
region_chunk_z: u8, | ||
}, | ||
/// Chunk length overlaps declared maximum. | ||
/// | ||
/// This should not occur under normal conditions. | ||
/// | ||
/// Region file are corrupted. | ||
LengthExceedsMaximum { | ||
/// Chunk length. | ||
length: u32, | ||
/// Chunk maximum expected length. | ||
maximum_length: u32, | ||
}, | ||
/// Currently are only 2 types of compression: Gzip and Zlib. | ||
/// | ||
/// This should not occur under normal conditions. | ||
/// | ||
/// Region file are corrupted or was introduced new compression type. | ||
UnsupportedCompressionScheme { | ||
/// Compression scheme type id. | ||
compression_scheme: u8, | ||
}, | ||
/// I/O Error which happened while were reading chunk data from region file. | ||
IOError { io_error: io::Error }, | ||
/// Error while decoding binary data to NBT tag. | ||
/// | ||
/// This should not occur under normal conditions. | ||
/// | ||
/// Region file are corrupted or a developer error in the NBT library. | ||
TagDecodeError { tag_decode_error: TagDecodeError }, | ||
} | ||
|
||
impl From<io::Error> for ChunkReadError { | ||
fn from(io_error: io::Error) -> Self { | ||
ChunkReadError::IOError { io_error } | ||
} | ||
} | ||
|
||
impl From<TagDecodeError> for ChunkReadError { | ||
fn from(tag_decode_error: TagDecodeError) -> Self { | ||
ChunkReadError::TagDecodeError { tag_decode_error } | ||
} | ||
} | ||
|
||
/// Possible errors while saving the chunk. | ||
#[derive(Debug)] | ||
pub enum ChunkWriteError { | ||
/// Chunk length exceeds 1 MB. | ||
/// | ||
/// This should not occur under normal conditions. | ||
LengthExceedsMaximum { | ||
/// Chunk length. | ||
length: u32, | ||
}, | ||
/// I/O Error which happened while were writing chunk data to region. | ||
IOError { io_error: io::Error }, | ||
} | ||
|
||
impl From<io::Error> for ChunkWriteError { | ||
fn from(io_error: io::Error) -> Self { | ||
ChunkWriteError::IOError { io_error } | ||
} | ||
} |
Oops, something went wrong.