signinum_core/sample.rs
1// SPDX-License-Identifier: Apache-2.0
2
3/// Integer sample width used by a pixel format or row sink.
4#[derive(Debug, Clone, Copy, PartialEq, Eq)]
5#[non_exhaustive]
6pub enum SampleType {
7 /// Unsigned 8-bit samples.
8 U8,
9 /// Unsigned 16-bit samples.
10 U16,
11}
12
13/// Supported integer sample type for row-oriented APIs.
14pub trait Sample: Copy + Default + Send + Sync + 'static {
15 /// Runtime sample type tag.
16 const TYPE: SampleType;
17 /// Number of significant bits in the sample type.
18 const BITS: u8;
19}
20
21impl Sample for u8 {
22 const TYPE: SampleType = SampleType::U8;
23 const BITS: u8 = 8;
24}
25
26impl Sample for u16 {
27 const TYPE: SampleType = SampleType::U16;
28 const BITS: u8 = 16;
29}