pub struct RegionReader<'a> { /* private fields */ }
Expand description
A Minecraft region
This struct is just a wrapper around &'a [u8]
but provides methods to get chunk byte slices & header data.
Implementations§
Source§impl<'a> RegionReader<'a>
impl<'a> RegionReader<'a>
Sourcepub fn new(data: &'a [u8]) -> Result<RegionReader<'a>, McaError>
pub fn new(data: &'a [u8]) -> Result<RegionReader<'a>, McaError>
Initializes a new region
Validates that the region size is at least the size of the header
Sourcepub fn chunk_offset(x: usize, z: usize) -> usize
pub fn chunk_offset(x: usize, z: usize) -> usize
Get a offset depending on the chunk coordinates.
Used in getting byte offsets for chunk location & timestamp in headers
Sourcepub fn get_location(&self, offset: usize) -> Option<[u8; 4]>
pub fn get_location(&self, offset: usize) -> Option<[u8; 4]>
Get the chunk payload location based off chunk coordinate byte offsets
Sourcepub fn get_timestamp(&self, offset: usize) -> Result<[u8; 4], McaError>
pub fn get_timestamp(&self, offset: usize) -> Result<[u8; 4], McaError>
Get the timestamp big endian bytes for the chunk based off chunk coordinate byte offsets
Sourcepub fn get_u32_timestamp(&self, timestamp_bytes: [u8; 4]) -> u32
pub fn get_u32_timestamp(&self, timestamp_bytes: [u8; 4]) -> u32
Converts the timestamp bytes to u32 unix epoch seconds
pub fn iter(&self) -> RegionIter<'_> ⓘ
Trait Implementations§
Source§impl<'a> Clone for RegionReader<'a>
impl<'a> Clone for RegionReader<'a>
Source§fn clone(&self) -> RegionReader<'a>
fn clone(&self) -> RegionReader<'a>
Returns a copy of the value. Read more
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source
. Read moreSource§impl<'a> Debug for RegionReader<'a>
impl<'a> Debug for RegionReader<'a>
Source§impl<'a> Ord for RegionReader<'a>
impl<'a> Ord for RegionReader<'a>
Source§fn cmp(&self, other: &RegionReader<'a>) -> Ordering
fn cmp(&self, other: &RegionReader<'a>) -> Ordering
1.21.0 · Source§fn max(self, other: Self) -> Selfwhere
Self: Sized,
fn max(self, other: Self) -> Selfwhere
Self: Sized,
Compares and returns the maximum of two values. Read more
Source§impl<'a> PartialEq for RegionReader<'a>
impl<'a> PartialEq for RegionReader<'a>
Source§impl<'a> PartialOrd for RegionReader<'a>
impl<'a> PartialOrd for RegionReader<'a>
impl<'a> Eq for RegionReader<'a>
impl<'a> StructuralPartialEq for RegionReader<'a>
Auto Trait Implementations§
impl<'a> Freeze for RegionReader<'a>
impl<'a> RefUnwindSafe for RegionReader<'a>
impl<'a> Send for RegionReader<'a>
impl<'a> Sync for RegionReader<'a>
impl<'a> Unpin for RegionReader<'a>
impl<'a> UnwindSafe for RegionReader<'a>
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more