Skip to main content

rustriff_lib/domain/dto/
tone_stack_dto.rs

1use crate::domain::tone_stack::ToneStack;
2use serde::{Deserialize, Serialize};
3use std::sync::atomic::Ordering;
4
5/// Data transfer object for tone stack parameters.
6///
7/// Used for serializing and deserializing tone stack data, typically for communication between
8/// the UI and backend. The bass, middle, and treble values are expected to be in the range 0.0 to 1.0.
9#[derive(Serialize, Deserialize, Clone, Debug)]
10pub struct ToneStackDto {
11    /// The bass level (0.0 to 1.0).
12    pub bass: f32,
13    /// The middle level (0.0 to 1.0).
14    pub middle: f32,
15    /// The treble level (0.0 to 1.0).
16    pub treble: f32,
17}
18
19impl From<&ToneStack> for ToneStackDto {
20    fn from(tone_stack: &ToneStack) -> Self {
21        Self {
22            bass: tone_stack.bass().load(Ordering::Relaxed),
23            middle: tone_stack.middle().load(Ordering::Relaxed),
24            treble: tone_stack.treble().load(Ordering::Relaxed),
25        }
26    }
27}