pub enum RegionRef<'a> {
Borrowed(&'a Region),
Owned(Box<Region>),
}
Expand description
A wrapper around Region
that allows either a reference to be used or a Box
over return types.
Deref
is implemented for this enum, so in theory, there should never be a need to match on
this.
This is primarily used in the RegionParser
trait, so that the implementers can return
either a reference to or a box of a Region
.
Variants§
Methods from Deref<Target = Region>§
Sourcepub fn validate(&self) -> Result<()>
pub fn validate(&self) -> Result<()>
Validate that this Region contains all valid chunks by trying to parse every chunk.
§Important Note
- This method is obviously slow and uses a decent amount of memory. It is
recommended to assume the data is correct and validate it as you use the
Region::get_chunk
andChunk::parse
methods. - This method should only be used when you absolutely need to validate the data is
correct and can’t use the
Region::get_chunk
andChunk::parse
methods
Sourcepub fn get_timestamp(&self, x: u32, z: u32) -> u32
pub fn get_timestamp(&self, x: u32, z: u32) -> u32
Sourcepub fn get_chunk(&self, chunk_x: u32, chunk_z: u32) -> Result<Option<&Chunk>>
pub fn get_chunk(&self, chunk_x: u32, chunk_z: u32) -> Result<Option<&Chunk>>
Get a chunk from this Region
using relative coordinates within the region
§Return Values
Err
if data is invalidOk(None)
if the data is valid, but there is no chunk generatedOk(Some(&Chunk))
if the data is valid and the chunk exists
This will return a &Chunk
which references this Region
, if you want an owned
version, call Chunk::boxed
on the returned chunk.
§Panics
- If
x
andz
are not within0..=31
Sourcepub fn get_chunk_from_block(
&self,
block_x: u32,
block_z: u32,
) -> Result<Option<&Chunk>>
pub fn get_chunk_from_block( &self, block_x: u32, block_z: u32, ) -> Result<Option<&Chunk>>
Get a chunk from this Region
using relative block coordinates within the region
§Return Values
Err
if data is invalidOk(None)
if the data is valid, but there is no chunk generatedOk(Some(&Chunk))
if the data is valid and the chunk exists
This will return a &Chunk
which references this Region
, if you want an owned
version, call Chunk::boxed
on the returned chunk.
§Panics
- If
x
andz
are not within0..=511