pub trait Sample:
Sealed
+ Copy
+ Send
+ Sync
+ 'static {
const KIND: SampleKind;
const FULL_SCALE: Self;
const ZERO: Self;
}Expand description
A channel sample type that kernels can be monomorphized over.
Implemented for exactly u8, u16 and f32 — the sample types of the v1
PixelFormat set. This trait is the type-level half of ADR-0002: ops
match on a runtime PixelFormat once per tile, then call a generic
kernel that the compiler specializes.
This trait is sealed: implementing it for other types would let a kernel reinterpret tile bytes as a type no codec produces.
Required Associated Constants§
Sourceconst KIND: SampleKind
const KIND: SampleKind
The SampleKind this type corresponds to.
Sourceconst FULL_SCALE: Self
const FULL_SCALE: Self
The value representing full intensity: opaque alpha, white luminance.
This is not the type’s maximum representable value. For f32 the
nominal range is 0.0..=1.0, so FULL_SCALE is 1.0 while
f32::MAX is about 3.4e38.
It is named FULL_SCALE rather than MAX precisely because of that
gap: u8, u16 and f32 all have an inherent MAX constant, and
inherent constants win name resolution over trait ones. A kernel
generic over S: Sample writing S::MAX would therefore compile,
resolve to the inherent constant, and be silently wrong for floats.
Dyn Compatibility§
This trait is not dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety".