1#[derive(Debug, rkyv::Archive, rkyv::Deserialize, rkyv::Serialize)]
2pub enum Uniform {
3 Color([f32; 3]),
4 Texture(u8),
5}
6
7#[cfg(feature = "safe")]
8impl ArchivedUniform {
9 pub(crate) const fn texture(&self) -> Option<u8> {
10 match self {
11 Self::Texture(t) => Some(*t),
12 _ => None,
13 }
14 }
15}
16
17impl Uniform {
18 pub const fn new_color(color: [f32; 3]) -> Self {
19 Self::Color(color)
20 }
21 pub const fn new_texture(data: u8) -> Self {
22 Self::Texture(data)
23 }
24 pub const fn color(&self) -> Option<&[f32; 3]> {
25 match self {
26 Self::Color(c) => Some(c),
27 _ => None,
28 }
29 }
30 pub const fn texture(&self) -> Option<u8> {
31 match self {
32 Self::Texture(t) => Some(*t),
33 _ => None,
34 }
35 }
36}
37
38impl Default for Uniform {
39 fn default() -> Self {
40 Self::Color([1.0; 3])
41 }
42}