Enum mca_parser::RegionRef
source · 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_chunkandChunk::parsemethods. - This method should only be used when you absolutely need to validate the data is
correct and can’t use the
Region::get_chunkandChunk::parsemethods
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
Errif 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
xandzare 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
Errif 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
xandzare not within0..=511