Skip to main content

nice_plug_core/plugin/
track_info.rs

1//! Information about the track a plugin is placed on, as reported by the host.
2
3/// Information about the track the plugin is currently placed on. Not all hosts provide this
4/// information, and not all fields may be available at once.
5#[derive(Debug, Clone, PartialEq, Default)]
6pub struct TrackInfo {
7    name: String,
8    color: Option<TrackColor>,
9}
10
11impl TrackInfo {
12    pub fn new(name: impl Into<String>, color: Option<TrackColor>) -> Self {
13        Self {
14            name: name.into(),
15            color,
16        }
17    }
18
19    pub fn name(&self) -> &str {
20        &self.name
21    }
22
23    pub fn color(&self) -> Option<TrackColor> {
24        self.color
25    }
26}
27
28/// An RGBA color associated with a track.
29#[derive(Debug, Clone, Copy, PartialEq, Eq)]
30pub struct TrackColor {
31    r: u8,
32    g: u8,
33    b: u8,
34    a: u8,
35}
36
37impl TrackColor {
38    pub const fn new(r: u8, g: u8, b: u8, a: u8) -> Self {
39        Self { r, g, b, a }
40    }
41
42    pub const fn rgba(self) -> (u8, u8, u8, u8) {
43        (self.r, self.g, self.b, self.a)
44    }
45}