Struct image_texel::layout::TexelLayout
source · [−]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
sourceimpl TexelLayout
impl TexelLayout
sourcepub fn from_pixel<P: AsTexel>() -> Self
pub fn from_pixel<P: AsTexel>() -> Self
Construct an element from a self-evident pixel.
sourcepub const MAX_SIZE: Self = {
TexelLayout {
size: isize::MAX as usize,
align: 1,
}
}
pub const MAX_SIZE: Self = { TexelLayout { size: isize::MAX as usize, align: 1, } }
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.
sourcepub fn with_layout(layout: Layout) -> Option<Self>
pub fn with_layout(layout: Layout) -> Option<Self>
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.
sourcepub fn layout(self) -> Layout
pub fn layout(self) -> Layout
Convert this into a type layout.
This can never fail as TexelLayout refines the standard library layout type.
sourcepub fn packed(self, align: usize) -> TexelLayout
pub fn packed(self, align: usize) -> TexelLayout
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.
sourcepub fn infimum(self, other: Self) -> TexelLayout
pub fn infimum(self, other: Self) -> TexelLayout
Create an element having the smaller of both sizes and alignments.
pub const fn superset_of(&self, other: TexelLayout) -> bool
Trait Implementations
sourceimpl Clone for TexelLayout
impl Clone for TexelLayout
sourcefn clone(&self) -> TexelLayout
fn clone(&self) -> TexelLayout
Returns a copy of the value. Read more
1.0.0 · sourcefn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from source. Read more
sourceimpl Debug for TexelLayout
impl Debug for TexelLayout
sourceimpl<P> From<Texel<P>> for TexelLayout
impl<P> From<Texel<P>> for TexelLayout
Convert a pixel to an element, discarding the exact type information.
sourceimpl Hash for TexelLayout
impl Hash for TexelLayout
sourceimpl Ord for TexelLayout
impl Ord for TexelLayout
sourceimpl PartialEq<TexelLayout> for TexelLayout
impl PartialEq<TexelLayout> for TexelLayout
sourcefn eq(&self, other: &TexelLayout) -> bool
fn eq(&self, other: &TexelLayout) -> bool
This method tests for self and other values to be equal, and is used
by ==. Read more
sourcefn ne(&self, other: &TexelLayout) -> bool
fn ne(&self, other: &TexelLayout) -> bool
This method tests for !=.
sourceimpl PartialOrd<TexelLayout> for TexelLayout
impl PartialOrd<TexelLayout> for TexelLayout
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);sourcefn partial_cmp(&self, other: &Self) -> Option<Ordering>
fn partial_cmp(&self, other: &Self) -> Option<Ordering>
This method returns an ordering between self and other values if one exists. Read more
1.0.0 · sourcefn lt(&self, other: &Rhs) -> bool
fn lt(&self, other: &Rhs) -> bool
This method tests less than (for self and other) and is used by the < operator. Read more
1.0.0 · sourcefn le(&self, other: &Rhs) -> bool
fn le(&self, other: &Rhs) -> bool
This method tests less than or equal to (for self and other) and is used by the <=
operator. Read more
impl Copy for TexelLayout
impl Eq for TexelLayout
impl StructuralEq for TexelLayout
impl StructuralPartialEq for TexelLayout
Auto Trait Implementations
impl RefUnwindSafe for TexelLayout
impl Send for TexelLayout
impl Sync for TexelLayout
impl Unpin for TexelLayout
impl UnwindSafe for TexelLayout
Blanket Implementations
sourceimpl<T> BorrowMut<T> for T where
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
const: unstable · sourcefn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
sourceimpl<T> ToOwned for T where
T: Clone,
impl<T> ToOwned for T where
T: Clone,
type Owned = T
type Owned = T
The resulting type after obtaining ownership.
sourcefn clone_into(&self, target: &mut T)
fn clone_into(&self, target: &mut T)
toowned_clone_into)Uses borrowed data to replace owned data, usually by cloning. Read more