Resolution

Enum Resolution 

Source
#[non_exhaustive]
#[repr(u8)]
pub enum Resolution { R1 = 0, R2 = 1, R4 = 2, R8 = 3, R16 = 4, R32 = 5, R64 = 6, R128 = 7, }
Expand description

Scale factor between a Block and its component voxels.

This resolution cubed is the number of voxels making up a block.

Resolutions are always powers of 2. This ensures that the arithmetic is well-behaved (no division by zero, exact floating-point representation, and the potential of fixed-point representation), and that it is always possible to subdivide a block further (up to the limit) without shifting the existing voxel boundaries.

Note that while quite high resolutions are permitted, this does not mean that it is practical to routinely use full blocks at that resolution. For example, 64 × 64 × 64 = 262,144 voxels, occupying several megabytes just for color data. High resolutions are permitted for special purposes that do not necessarily use the full cube volume:

  • Thin blocks (e.g. 128 × 128 × 1) can display high resolution text and other 2D images.
  • Multi-block structures can be defined using Modifier::Zoom; their total size is limited by the resolution limit.

Variants (Non-exhaustive)§

This enum is marked as non-exhaustive
Non-exhaustive enums could have additional variants added in future. Therefore, when matching against variants of non-exhaustive enums, an extra wildcard arm must be added to account for any future variants.
§

R1 = 0

§

R2 = 1

§

R4 = 2

§

R8 = 3

§

R16 = 4

§

R32 = 5

§

R64 = 6

§

R128 = 7

Implementations§

Source§

impl Resolution

Source

pub const MAX: Resolution = Resolution::R128

The maximum available resolution.

Source

pub const fn double(self) -> Option<Resolution>

Returns the Resolution that’s twice this one, or None at the limit.

Source

pub const fn halve(self) -> Option<Resolution>

Returns the Resolution that’s half this one, or None if self is R1.

Source

pub const fn log2(self) -> u8

Returns the logarithm base 2 of this resolution.

This is always an exact integer value; all resolutions are powers of 2.

§Example

assert_eq!(Resolution::R1.log2(), 0);
assert_eq!(Resolution::R16.log2(), 4);
Source

pub const fn recip_f32(self) -> f32

Returns the reciprocal of this resolution; that is, the scale factor from voxels to blocks of this resolution.

Equivalent to f32::from(self).recip() but does not perform division.

Source

pub const fn recip_f64(self) -> f64

Returns the reciprocal of this resolution; that is, the scale factor from voxels to blocks of this resolution.

Equivalent to f64::from(self).recip() but does not perform division.

Trait Implementations§

Source§

impl<'arbitrary> Arbitrary<'arbitrary> for Resolution

Source§

fn arbitrary(u: &mut Unstructured<'arbitrary>) -> Result<Resolution, Error>

Generate an arbitrary value of Self from the given unstructured data. Read more
Source§

fn arbitrary_take_rest(u: Unstructured<'arbitrary>) -> Result<Resolution, Error>

Generate an arbitrary value of Self from the entirety of the given unstructured data. Read more
Source§

fn size_hint(depth: usize) -> (usize, Option<usize>)

Get a size hint for how many bytes out of an Unstructured this type needs to construct itself. Read more
Source§

fn try_size_hint( depth: usize, ) -> Result<(usize, Option<usize>), MaxRecursionReached>

Get a size hint for how many bytes out of an Unstructured this type needs to construct itself. Read more
Source§

impl Clone for Resolution

Source§

fn clone(&self) -> Resolution

Returns a duplicate of the value. Read more
1.0.0 · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for Resolution

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result<(), Error>

Formats the value using the given formatter. Read more
Source§

impl<'de> Deserialize<'de> for Resolution

Available on crate feature serde only.
Source§

fn deserialize<D>( deserializer: D, ) -> Result<Resolution, <D as Deserializer<'de>>::Error>
where D: Deserializer<'de>,

Deserialize this value from the given Serde deserializer. Read more
Source§

impl Display for Resolution

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result<(), Error>

Formats the value using the given formatter. Read more
Source§

impl Div for Resolution

Source§

type Output = Option<Resolution>

The resulting type after applying the / operator.
Source§

fn div(self, rhs: Resolution) -> <Resolution as Div>::Output

Performs the / operation. Read more
Source§

impl Exhaust for Resolution

Source§

type Iter = ExhaustResolutionIter

Iterator type returned by Self::exhaust_factories(). See the trait documentation for what properties this iterator should have. Read more
Source§

type Factory = ExhaustResolutionFactory

Data which can be used to construct Self. Read more
Source§

fn exhaust_factories() -> <Resolution as Exhaust>::Iter

Returns an iterator over factories for all values of this type. Read more
Source§

fn from_factory(factory: <Resolution as Exhaust>::Factory) -> Resolution

Construct a concrete value of this type from a Self::Factory value produced by its Self::Iter. Read more
Source§

fn exhaust() -> Iter<Self>

Returns an iterator over all values of this type. Read more
Source§

impl Hash for Resolution

Source§

fn hash<__H>(&self, state: &mut __H)
where __H: Hasher,

Feeds this value into the given Hasher. Read more
1.3.0 · Source§

fn hash_slice<H>(data: &[Self], state: &mut H)
where H: Hasher, Self: Sized,

Feeds a slice of this type into the given Hasher. Read more
Source§

impl Mul for Resolution

Source§

type Output = Option<Resolution>

The resulting type after applying the * operator.
Source§

fn mul(self, rhs: Resolution) -> <Resolution as Mul>::Output

Performs the * operation. Read more
Source§

impl Ord for Resolution

Source§

fn cmp(&self, other: &Resolution) -> Ordering

This method returns an Ordering between self and other. Read more
1.21.0 · Source§

fn max(self, other: Self) -> Self
where Self: Sized,

Compares and returns the maximum of two values. Read more
1.21.0 · Source§

fn min(self, other: Self) -> Self
where Self: Sized,

Compares and returns the minimum of two values. Read more
1.50.0 · Source§

fn clamp(self, min: Self, max: Self) -> Self
where Self: Sized,

Restrict a value to a certain interval. Read more
Source§

impl PartialEq for Resolution

Source§

fn eq(&self, other: &Resolution) -> bool

Tests for self and other values to be equal, and is used by ==.
1.0.0 · Source§

fn ne(&self, other: &Rhs) -> bool

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
Source§

impl PartialOrd for Resolution

Source§

fn partial_cmp(&self, other: &Resolution) -> Option<Ordering>

This method returns an ordering between self and other values if one exists. Read more
1.0.0 · Source§

fn lt(&self, other: &Rhs) -> bool

Tests less than (for self and other) and is used by the < operator. Read more
1.0.0 · Source§

fn le(&self, other: &Rhs) -> bool

Tests less than or equal to (for self and other) and is used by the <= operator. Read more
1.0.0 · Source§

fn gt(&self, other: &Rhs) -> bool

Tests greater than (for self and other) and is used by the > operator. Read more
1.0.0 · Source§

fn ge(&self, other: &Rhs) -> bool

Tests greater than or equal to (for self and other) and is used by the >= operator. Read more
Source§

impl Serialize for Resolution

Available on crate feature serde only.
Source§

fn serialize<S>( &self, serializer: S, ) -> Result<<S as Serializer>::Ok, <S as Serializer>::Error>
where S: Serializer,

Serialize this value into the given Serde serializer. Read more
Source§

impl TryFrom<i128> for Resolution

Source§

type Error = IntoResolutionError<i128>

The type returned in the event of a conversion error.
Source§

fn try_from( value: i128, ) -> Result<Resolution, <Resolution as TryFrom<i128>>::Error>

Performs the conversion.
Source§

impl TryFrom<i16> for Resolution

Source§

type Error = IntoResolutionError<i16>

The type returned in the event of a conversion error.
Source§

fn try_from( value: i16, ) -> Result<Resolution, <Resolution as TryFrom<i16>>::Error>

Performs the conversion.
Source§

impl TryFrom<i32> for Resolution

Source§

type Error = IntoResolutionError<i32>

The type returned in the event of a conversion error.
Source§

fn try_from( value: i32, ) -> Result<Resolution, <Resolution as TryFrom<i32>>::Error>

Performs the conversion.
Source§

impl TryFrom<i64> for Resolution

Source§

type Error = IntoResolutionError<i64>

The type returned in the event of a conversion error.
Source§

fn try_from( value: i64, ) -> Result<Resolution, <Resolution as TryFrom<i64>>::Error>

Performs the conversion.
Source§

impl TryFrom<isize> for Resolution

Source§

type Error = IntoResolutionError<isize>

The type returned in the event of a conversion error.
Source§

fn try_from( value: isize, ) -> Result<Resolution, <Resolution as TryFrom<isize>>::Error>

Performs the conversion.
Source§

impl TryFrom<u128> for Resolution

Source§

type Error = IntoResolutionError<u128>

The type returned in the event of a conversion error.
Source§

fn try_from( value: u128, ) -> Result<Resolution, <Resolution as TryFrom<u128>>::Error>

Performs the conversion.
Source§

impl TryFrom<u16> for Resolution

Source§

type Error = IntoResolutionError<u16>

The type returned in the event of a conversion error.
Source§

fn try_from( value: u16, ) -> Result<Resolution, <Resolution as TryFrom<u16>>::Error>

Performs the conversion.
Source§

impl TryFrom<u32> for Resolution

Source§

type Error = IntoResolutionError<u32>

The type returned in the event of a conversion error.
Source§

fn try_from( value: u32, ) -> Result<Resolution, <Resolution as TryFrom<u32>>::Error>

Performs the conversion.
Source§

impl TryFrom<u64> for Resolution

Source§

type Error = IntoResolutionError<u64>

The type returned in the event of a conversion error.
Source§

fn try_from( value: u64, ) -> Result<Resolution, <Resolution as TryFrom<u64>>::Error>

Performs the conversion.
Source§

impl TryFrom<usize> for Resolution

Source§

type Error = IntoResolutionError<usize>

The type returned in the event of a conversion error.
Source§

fn try_from( value: usize, ) -> Result<Resolution, <Resolution as TryFrom<usize>>::Error>

Performs the conversion.
Source§

impl Copy for Resolution

Source§

impl Eq for Resolution

Source§

impl StructuralPartialEq for Resolution

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Az for T

Source§

fn az<Dst>(self) -> Dst
where T: Cast<Dst>,

Casts the value.
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<Src, Dst> CastFrom<Src> for Dst
where Src: Cast<Dst>,

Source§

fn cast_from(src: Src) -> Dst

Casts the value.
Source§

impl<T> CheckedAs for T

Source§

fn checked_as<Dst>(self) -> Option<Dst>
where T: CheckedCast<Dst>,

Casts the value.
Source§

impl<Src, Dst> CheckedCastFrom<Src> for Dst
where Src: CheckedCast<Dst>,

Source§

fn checked_cast_from(src: Src) -> Option<Dst>

Casts the value.
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<Q, K> Comparable<K> for Q
where Q: Ord + ?Sized, K: Borrow<Q> + ?Sized,

Source§

fn compare(&self, key: &K) -> Ordering

Compare self to key and return their ordering.
Source§

impl<T> DynEq for T
where T: Any + Eq,

Source§

fn as_any(&self) -> &(dyn Any + 'static)

Casts the type to dyn Any.
Source§

fn dyn_eq(&self, other: &(dyn DynEq + 'static)) -> bool

This method tests for self and other values to be equal. Read more
Source§

impl<T> DynHash for T
where T: DynEq + Hash,

Source§

fn as_dyn_eq(&self) -> &(dyn DynEq + 'static)

Casts the type to dyn Any.
Source§

fn dyn_hash(&self, state: &mut dyn Hasher)

Feeds this value into the given Hasher.
Source§

impl<Q, K> Equivalent<K> for Q
where Q: Eq + ?Sized, K: Borrow<Q> + ?Sized,

Source§

fn equivalent(&self, key: &K) -> bool

Compare self to key and return true if they are equal.
Source§

impl<Q, K> Equivalent<K> for Q
where Q: Eq + ?Sized, K: Borrow<Q> + ?Sized,

Source§

fn equivalent(&self, key: &K) -> bool

Checks if this value is equivalent to the given key. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> IntoEither for T

Source§

fn into_either(self, into_left: bool) -> Either<Self, Self>

Converts 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 more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
where F: FnOnce(&Self) -> bool,

Converts 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 more
Source§

impl<T> OverflowingAs for T

Source§

fn overflowing_as<Dst>(self) -> (Dst, bool)
where T: OverflowingCast<Dst>,

Casts the value.
Source§

impl<Src, Dst> OverflowingCastFrom<Src> for Dst
where Src: OverflowingCast<Dst>,

Source§

fn overflowing_cast_from(src: Src) -> (Dst, bool)

Casts the value.
Source§

impl<T> SaturatingAs for T

Source§

fn saturating_as<Dst>(self) -> Dst
where T: SaturatingCast<Dst>,

Casts the value.
Source§

impl<Src, Dst> SaturatingCastFrom<Src> for Dst
where Src: SaturatingCast<Dst>,

Source§

fn saturating_cast_from(src: Src) -> Dst

Casts the value.
Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T> ToString for T
where T: Display + ?Sized,

Source§

fn to_string(&self) -> String

Converts the given value to a String. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<T> UnwrappedAs for T

Source§

fn unwrapped_as<Dst>(self) -> Dst
where T: UnwrappedCast<Dst>,

Casts the value.
Source§

impl<Src, Dst> UnwrappedCastFrom<Src> for Dst
where Src: UnwrappedCast<Dst>,

Source§

fn unwrapped_cast_from(src: Src) -> Dst

Casts the value.
Source§

impl<T> WrappingAs for T

Source§

fn wrapping_as<Dst>(self) -> Dst
where T: WrappingCast<Dst>,

Casts the value.
Source§

impl<Src, Dst> WrappingCastFrom<Src> for Dst
where Src: WrappingCast<Dst>,

Source§

fn wrapping_cast_from(src: Src) -> Dst

Casts the value.
Source§

impl<T> ConditionalSend for T
where T: Send,

Source§

impl<T> DeserializeOwned for T
where T: for<'de> Deserialize<'de>,