pub struct DataLayer {
data: Option<Box<[u8; 2048]>>,
default_value: u8,
}Expand description
Packed 4-bit light values for one 16x16x16 light section.
This mirrors vanilla’s DataLayer: values are indexed as
y << 8 | z << 4 | x, with two light nibbles packed into each byte. A
homogeneous layer stores only a default value until bytes are needed.
Fields§
§data: Option<Box<[u8; 2048]>>§default_value: u8Implementations§
Source§impl DataLayer
impl DataLayer
Sourcepub fn from_bytes(bytes: Box<[u8]>) -> Result<Self, DataLayerLengthError>
pub fn from_bytes(bytes: Box<[u8]>) -> Result<Self, DataLayerLengthError>
Creates a layer from packed vanilla bytes.
Sourcepub(crate) const fn from_packed_data(data: Box<[u8; 2048]>) -> Self
pub(crate) const fn from_packed_data(data: Box<[u8; 2048]>) -> Self
Creates a layer from already length-checked packed vanilla bytes.
Sourcepub fn get(&self, x: usize, y: usize, z: usize) -> u8
pub fn get(&self, x: usize, y: usize, z: usize) -> u8
Returns the light value at local section coordinates.
Sourcepub fn set(&mut self, x: usize, y: usize, z: usize, value: u8)
pub fn set(&mut self, x: usize, y: usize, z: usize, value: u8)
Sets the light value at local section coordinates.
Sourcepub const fn is_homogeneous(&self) -> bool
pub const fn is_homogeneous(&self) -> bool
Returns true when the layer is represented by one homogeneous value.
Sourcepub const fn homogeneous_value(&self) -> Option<u8>
pub const fn homogeneous_value(&self) -> Option<u8>
Returns the homogeneous value when no packed data exists.
Sourcepub const fn is_filled_with(&self, value: u8) -> bool
pub const fn is_filled_with(&self, value: u8) -> bool
Returns true when the layer is known to be filled with value.
Sourcepub const fn is_empty(&self) -> bool
pub const fn is_empty(&self) -> bool
Returns true when this layer is an all-zero homogeneous layer.
Sourcepub fn is_all_zero(&self) -> bool
pub fn is_all_zero(&self) -> bool
Returns true when all packed values are zero.
Sourcepub fn to_bytes(&self) -> Box<[u8; 2048]>
pub fn to_bytes(&self) -> Box<[u8; 2048]>
Returns packed bytes without changing the layer representation.
fn get_at_index(&self, index: usize) -> u8
fn set_at_index(&mut self, index: usize, value: u8)
const fn index(x: usize, y: usize, z: usize) -> usize
const fn byte_index(index: usize) -> usize
const fn nibble_index(index: usize) -> usize
const fn pack_filled(value: u8) -> u8
Trait Implementations§
impl Eq for DataLayer
impl StructuralPartialEq for DataLayer
Auto Trait Implementations§
impl Freeze for DataLayer
impl RefUnwindSafe for DataLayer
impl Send for DataLayer
impl Sync for DataLayer
impl Unpin for DataLayer
impl UnsafeUnpin for DataLayer
impl UnwindSafe for DataLayer
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
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
key and return true if they are equal.§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
self with key and returns true if they are equal.§impl<T> Instrument for T
impl<T> Instrument for T
§fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreArc<SyncMutex<>>