use maudio_sys::ffi as sys;

use crate::{ErrorKinds, MaudioError};

struct NodeBuilder {
    inner: sys::ma_node_config,
}

#[derive(Debug, Clone, Copy, PartialEq, Eq)]
#[repr(C)]
pub enum NodeState {
    Started,
    Stopped,
}

impl From<NodeState> for sys::ma_node_state {
    fn from(value: NodeState) -> Self {
        match value {
            NodeState::Started => sys::ma_node_state_ma_node_state_started,
            NodeState::Stopped => sys::ma_node_state_ma_node_state_stopped,
        }
    }
}

impl TryFrom<sys::ma_node_state> for NodeState {
    type Error = MaudioError;

    fn try_from(value: sys::ma_pan_mode) -> Result<Self, Self::Error> {
        match value {
            sys::ma_node_state_ma_node_state_started => Ok(NodeState::Started),
            sys::ma_node_state_ma_node_state_stopped => Ok(NodeState::Stopped),
            other => Err(MaudioError::new_ma_error(ErrorKinds::unknown_enum::<
                NodeState,
            >(other as i64))),
        }
    }
}
