Expand description
Constants for predefined texel types.
Holding an instance of Texel<T>
certifies that the type T
is compatible with the texel
concept, that is: its alignment requirement is small enough, its size is non-zero, it does
not contain any padding, and it is a plain old data type without any inner invariants
(including sharing predicates). These assertions allow a number of operations such as
reinterpreting aligned byte slices, writing to and read from byte buffers, fallible cast to
other texels, etc.
For types that guarantee the property, see AsTexel
and its impls.
§Extending
The recommended method of extending this with a custom type is by implementing bytemuck::Pod
for this type. This applies a number of consistency checks.
use bytemuck::{Pod, Zeroable};
use image_texel::{AsTexel, Texel};
#[derive(Clone, Copy, Pod, Zeroable)]
#[repr(C)]
struct Rgb(pub [u8; 3]);
impl AsTexel for Rgb {
fn texel() -> Texel<Rgb> {
Texel::for_type().expect("verified by bytemuck and image_texel")
}
}
impl Rgb {
const TEXEL: Texel<Self> = match Texel::for_type() {
Some(texel) => texel,
None => panic!("compilation error"),
};
}
Structs§
- Atomic
Buffer - Allocates and manages atomically shared bytes.
- Atomic
Ref - A logical reference to a typed element from some atomic memory.
- Atomic
Slice Ref - A logical reference to a byte slice from some atomic memory.
- Buffer
- Allocates and manages raw bytes.
- Cell
Buffer - Allocates and manages unsynchronized shared bytes.
- IsTransparent
Wrapper - Marker struct to denote that P is transparently wrapped in O.
- MaxAligned
- A byte-like-type that is aligned to the required max alignment.
- MaxAtomic
- Atomic equivalence of
MaxAligned
. - MaxCell
- A cell of a byte array equivalent to
MaxAligned
. - Texel
Range - A range representation that casts bytes to a specific texel type.
- atomic_
buf - An aligned slice of atomic memory.
- buf
- An aligned slice of memory.
- cell_
buf - An aligned slice of shared-access memory.