pub struct TexelLayout { /* private fields */ }
Expand description

Describes the byte layout of an texture element, untyped.

This is not so different from Texel and Layout but is a combination of both. It has the same invariants on alignment as the former which being untyped like the latter. The alignment of an element must be at most that of MaxAligned and the size must be a multiple of its alignment.

This type is a lower semi lattice. That is, given two elements the type formed by taking the minimum of size and alignment individually will always form another valid element. This operation is implemented in the Self::infimum method.

Implementations

Construct an element from a self-evident pixel.

An element with maximum size and no alignment requirements.

This constructor is mainly useful for the purpose of using it as a modifier. When used with Self::infimum it will only shrink the alignment and keep the size unchanged.

Create an element for a fictional type with specific layout.

It’s up to the caller to define or use an actual type with that same layout later. This skips the check that such a type must not contain any padding and only performs the layout related checks.

Convert this into a type layout.

This can never fail as TexelLayout refines the standard library layout type.

Reduce the alignment of the element.

This will perform the same modification as repr(packed) on the element’s type.

Panics

This method panics if align is not a valid alignment.

Create an element having the smaller of both sizes and alignments.

Get the size of the element.

Get the minimum required alignment of the element.

Trait Implementations

Returns a copy of the value. Read more

Performs copy-assignment from source. Read more

Formats the value using the given formatter. Read more

Convert a pixel to an element, discarding the exact type information.

Converts to this type from the input type.

Feeds this value into the given Hasher. Read more

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

This method returns an Ordering between self and other. Read more

Compares and returns the maximum of two values. Read more

Compares and returns the minimum of two values. Read more

Restrict a value to a certain interval. Read more

This method tests for self and other values to be equal, and is used by ==. Read more

This method tests for !=.

The partial order of elements is defined by comparing size and alignment.

This turns it into a semi-lattice structure, with infimum implementing the meet operation. For example, the following comparison all hold:

let u8 = TexelLayout::from(U8);
let u8x2 = TexelLayout::from(U8.array::<2>());
let u8x3 = TexelLayout::from(U8.array::<3>());
let u16 = TexelLayout::from(U16);

assert!(u8 < u16, "due to size and alignment");
assert!(u8x2 < u16, "due to its alignment");
assert!(!(u8x3 < u16) && !(u16 < u8x3), "not comparable");

let meet = u8x3.infimum(u16);
assert!(meet <= u8x3);
assert!(meet <= u16);
assert!(meet == u16.packed(1), "We know it precisely here {:?}", meet);

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

This method tests less than (for self and other) and is used by the < operator. Read more

This method tests less than or equal to (for self and other) and is used by the <= operator. Read more

This method tests greater than (for self and other) and is used by the > operator. Read more

This method tests greater than or equal to (for self and other) and is used by the >= operator. Read more

Auto Trait Implementations

Blanket Implementations

Gets the TypeId of self. Read more

Immutably borrows from an owned value. Read more

Mutably borrows from an owned value. Read more

Returns the argument unchanged.

Calls U::from(self).

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

The resulting type after obtaining ownership.

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

🔬 This is a nightly-only experimental API. (toowned_clone_into)

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

The type returned in the event of a conversion error.

Performs the conversion.

The type returned in the event of a conversion error.

Performs the conversion.