eqtui 0.1.1-alpha.6

Terminal-native(TUI) audio effects processor for PipeWire
// Copyright (C) 2026 SiputBiru <hillsforrest03@gmail.com>
// SPDX-License-Identifier: GPL-2.0-only

use serde::{Deserialize, Serialize};

use crate::state::{EqBand, FilterState, NodeInfo, NullSinkState};

#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(tag = "cmd")]
pub enum Request {
    GetStatus,
    SetBands { bands: Vec<EqBand> },
    SetPreamp { gain: f32 },
    SetBypass { bypass: bool },
    ConnectDevice { node_id: u32 },
    DisconnectDevice { node_id: u32 },
    Shutdown,
}

#[derive(Debug, Clone, Serialize, Deserialize)]
pub struct Response {
    pub ok: bool,
    #[serde(skip_serializing_if = "Option::is_none")]
    pub error: Option<String>,
    #[serde(skip_serializing_if = "Option::is_none")]
    pub status: Option<DaemonStatus>,
}

#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(tag = "event")]
pub enum PushEvent {
    PeakUpdate {
        l: f32,
        r: f32,
    },
    NodeList {
        nodes: Vec<NodeInfo>,
    },
    FilterReady {
        node_id: u32,
    },
    /// Sent when the `pw_filter` state changes (STREAMING, ERROR, etc.).
    /// The TUI uses this to update the monitoring panel state line.
    FilterStateChanged {
        state: FilterState,
    },
    StateChange {
        state: String,
    },
    NullSinkCreated {
        module_id: u32,
    },
    SourceActive {
        active: bool,
    },
    /// Sent when `pw-link -I` failed and the null-sink input source
    /// state could not be determined.
    SourceUnknown,
    /// Sent once when the null-audio-sink could not be created.
    /// The filter runs but processes silence — no audio source is wired.
    NullSinkMissing,
    Error {
        message: String,
    },
}

#[derive(Debug, Clone, Serialize, Deserialize)]
pub struct DaemonStatus {
    pub bands: Vec<EqBand>,
    pub bypass: bool,
    pub preamp: f32,
    pub nodes: Vec<NodeInfo>,
    pub pw_connected: bool,
    pub filter_state: FilterState,
    pub null_sink: NullSinkState,
    pub filter_node_id: Option<u32>,
    pub connected_devices: Vec<u32>,
}