libsixel_rs/quant/
tuple.rs1use alloc::vec::Vec;
2
3pub type Sample = u32;
5
6pub type Tuple = Vec<Sample>;
8
9#[derive(Clone, Debug, PartialEq)]
11#[repr(C)]
12pub struct TupleInt {
13 pub value: u32,
14 pub tuple: Tuple,
15}
16
17impl TupleInt {
18 pub const fn new() -> Self {
20 Self {
21 value: 0,
22 tuple: Tuple::new(),
23 }
24 }
25
26 pub fn with_depth(depth: usize) -> Self {
28 Self {
29 value: 0,
30 tuple: vec![0; depth],
31 }
32 }
33
34 pub const fn value(&self) -> u32 {
36 self.value
37 }
38
39 pub fn set_value(&mut self, value: u32) {
41 self.value = value;
42 }
43
44 pub fn tuple(&self) -> &[Sample] {
46 self.tuple.as_ref()
47 }
48
49 pub fn set_tuple<V: Into<Tuple>>(&mut self, tuple: V) {
51 self.tuple = tuple.into();
52 }
53}