// This file was generated by gir (https://github.com/gtk-rs/gir)
// from
// from gir-files (https://github.com/gtk-rs/gir-files)
// DO NOT EDIT

use glib::error::ErrorDomain;
use glib::translate::*;
use glib::value::FromValue;
use glib::value::ToValue;
use glib::Quark;
use glib::StaticType;
use glib::Type;
use std::fmt;

#[derive(Debug, Eq, PartialEq, Ord, PartialOrd, Hash, Clone, Copy)]
#[non_exhaustive]
#[doc(alias = "ALSACtlCardError")]
pub enum CardError {
    #[doc(alias = "ALSACTL_CARD_ERROR_FAILED")]
    Failed,
    #[doc(alias = "ALSACTL_CARD_ERROR_DISCONNECTED")]
    Disconnected,
    #[doc(alias = "ALSACTL_CARD_ERROR_ELEM_NOT_FOUND")]
    ElemNotFound,
    #[doc(alias = "ALSACTL_CARD_ERROR_ELEM_NOT_SUPPORTED")]
    ElemNotSupported,
    #[doc(alias = "ALSACTL_CARD_ERROR_ELEM_OWNED")]
    ElemOwned,
    #[doc(alias = "ALSACTL_CARD_ERROR_ELEM_EXIST")]
    ElemExist,
    #[doc(hidden)]
    __Unknown(i32),
}

impl fmt::Display for CardError {
    fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
        write!(
            f,
            "CardError::{}",
            match *self {
                Self::Failed => "Failed",
                Self::Disconnected => "Disconnected",
                Self::ElemNotFound => "ElemNotFound",
                Self::ElemNotSupported => "ElemNotSupported",
                Self::ElemOwned => "ElemOwned",
                Self::ElemExist => "ElemExist",
                _ => "Unknown",
            }
        )
    }
}

#[doc(hidden)]
impl IntoGlib for CardError {
    type GlibType = ffi::ALSACtlCardError;

    fn into_glib(self) -> ffi::ALSACtlCardError {
        match self {
            Self::Failed => ffi::ALSACTL_CARD_ERROR_FAILED,
            Self::Disconnected => ffi::ALSACTL_CARD_ERROR_DISCONNECTED,
            Self::ElemNotFound => ffi::ALSACTL_CARD_ERROR_ELEM_NOT_FOUND,
            Self::ElemNotSupported => ffi::ALSACTL_CARD_ERROR_ELEM_NOT_SUPPORTED,
            Self::ElemOwned => ffi::ALSACTL_CARD_ERROR_ELEM_OWNED,
            Self::ElemExist => ffi::ALSACTL_CARD_ERROR_ELEM_EXIST,
            Self::__Unknown(value) => value,
        }
    }
}

#[doc(hidden)]
impl FromGlib<ffi::ALSACtlCardError> for CardError {
    unsafe fn from_glib(value: ffi::ALSACtlCardError) -> Self {
        match value {
            ffi::ALSACTL_CARD_ERROR_FAILED => Self::Failed,
            ffi::ALSACTL_CARD_ERROR_DISCONNECTED => Self::Disconnected,
            ffi::ALSACTL_CARD_ERROR_ELEM_NOT_FOUND => Self::ElemNotFound,
            ffi::ALSACTL_CARD_ERROR_ELEM_NOT_SUPPORTED => Self::ElemNotSupported,
            ffi::ALSACTL_CARD_ERROR_ELEM_OWNED => Self::ElemOwned,
            ffi::ALSACTL_CARD_ERROR_ELEM_EXIST => Self::ElemExist,
            value => Self::__Unknown(value),
        }
    }
}

impl ErrorDomain for CardError {
    fn domain() -> Quark {
        unsafe { from_glib(ffi::alsactl_card_error_quark()) }
    }

    fn code(self) -> i32 {
        self.into_glib()
    }

    fn from(code: i32) -> Option<Self> {
        match code {
            ffi::ALSACTL_CARD_ERROR_FAILED => Some(Self::Failed),
            ffi::ALSACTL_CARD_ERROR_DISCONNECTED => Some(Self::Disconnected),
            ffi::ALSACTL_CARD_ERROR_ELEM_NOT_FOUND => Some(Self::ElemNotFound),
            ffi::ALSACTL_CARD_ERROR_ELEM_NOT_SUPPORTED => Some(Self::ElemNotSupported),
            ffi::ALSACTL_CARD_ERROR_ELEM_OWNED => Some(Self::ElemOwned),
            ffi::ALSACTL_CARD_ERROR_ELEM_EXIST => Some(Self::ElemExist),
            _ => Some(Self::Failed),
        }
    }
}

impl StaticType for CardError {
    fn static_type() -> Type {
        unsafe { from_glib(ffi::alsactl_card_error_get_type()) }
    }
}

impl glib::value::ValueType for CardError {
    type Type = Self;
}

unsafe impl<'a> FromValue<'a> for CardError {
    type Checker = glib::value::GenericValueTypeChecker<Self>;

    unsafe fn from_value(value: &'a glib::Value) -> Self {
        from_glib(glib::gobject_ffi::g_value_get_enum(value.to_glib_none().0))
    }
}

impl ToValue for CardError {
    fn to_value(&self) -> glib::Value {
        let mut value = glib::Value::for_value_type::<Self>();
        unsafe {
            glib::gobject_ffi::g_value_set_enum(value.to_glib_none_mut().0, self.into_glib());
        }
        value
    }

    fn value_type(&self) -> glib::Type {
        Self::static_type()
    }
}

#[derive(Debug, Eq, PartialEq, Ord, PartialOrd, Hash, Clone, Copy)]
#[non_exhaustive]
#[doc(alias = "ALSACtlElemIfaceType")]
pub enum ElemIfaceType {
    #[doc(alias = "ALSACTL_ELEM_IFACE_TYPE_CARD")]
    Card,
    #[doc(alias = "ALSACTL_ELEM_IFACE_TYPE_HWDEP")]
    Hwdep,
    #[doc(alias = "ALSACTL_ELEM_IFACE_TYPE_MIXER")]
    Mixer,
    #[doc(alias = "ALSACTL_ELEM_IFACE_TYPE_PCM")]
    Pcm,
    #[doc(alias = "ALSACTL_ELEM_IFACE_TYPE_RAWMIDI")]
    Rawmidi,
    #[doc(alias = "ALSACTL_ELEM_IFACE_TYPE_TIMER")]
    Timer,
    #[doc(alias = "ALSACTL_ELEM_IFACE_TYPE_SEQUENCER")]
    Sequencer,
    #[doc(hidden)]
    __Unknown(i32),
}

impl fmt::Display for ElemIfaceType {
    fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
        write!(
            f,
            "ElemIfaceType::{}",
            match *self {
                Self::Card => "Card",
                Self::Hwdep => "Hwdep",
                Self::Mixer => "Mixer",
                Self::Pcm => "Pcm",
                Self::Rawmidi => "Rawmidi",
                Self::Timer => "Timer",
                Self::Sequencer => "Sequencer",
                _ => "Unknown",
            }
        )
    }
}

#[doc(hidden)]
impl IntoGlib for ElemIfaceType {
    type GlibType = ffi::ALSACtlElemIfaceType;

    fn into_glib(self) -> ffi::ALSACtlElemIfaceType {
        match self {
            Self::Card => ffi::ALSACTL_ELEM_IFACE_TYPE_CARD,
            Self::Hwdep => ffi::ALSACTL_ELEM_IFACE_TYPE_HWDEP,
            Self::Mixer => ffi::ALSACTL_ELEM_IFACE_TYPE_MIXER,
            Self::Pcm => ffi::ALSACTL_ELEM_IFACE_TYPE_PCM,
            Self::Rawmidi => ffi::ALSACTL_ELEM_IFACE_TYPE_RAWMIDI,
            Self::Timer => ffi::ALSACTL_ELEM_IFACE_TYPE_TIMER,
            Self::Sequencer => ffi::ALSACTL_ELEM_IFACE_TYPE_SEQUENCER,
            Self::__Unknown(value) => value,
        }
    }
}

#[doc(hidden)]
impl FromGlib<ffi::ALSACtlElemIfaceType> for ElemIfaceType {
    unsafe fn from_glib(value: ffi::ALSACtlElemIfaceType) -> Self {
        match value {
            ffi::ALSACTL_ELEM_IFACE_TYPE_CARD => Self::Card,
            ffi::ALSACTL_ELEM_IFACE_TYPE_HWDEP => Self::Hwdep,
            ffi::ALSACTL_ELEM_IFACE_TYPE_MIXER => Self::Mixer,
            ffi::ALSACTL_ELEM_IFACE_TYPE_PCM => Self::Pcm,
            ffi::ALSACTL_ELEM_IFACE_TYPE_RAWMIDI => Self::Rawmidi,
            ffi::ALSACTL_ELEM_IFACE_TYPE_TIMER => Self::Timer,
            ffi::ALSACTL_ELEM_IFACE_TYPE_SEQUENCER => Self::Sequencer,
            value => Self::__Unknown(value),
        }
    }
}

impl StaticType for ElemIfaceType {
    fn static_type() -> Type {
        unsafe { from_glib(ffi::alsactl_elem_iface_type_get_type()) }
    }
}

impl glib::value::ValueType for ElemIfaceType {
    type Type = Self;
}

unsafe impl<'a> FromValue<'a> for ElemIfaceType {
    type Checker = glib::value::GenericValueTypeChecker<Self>;

    unsafe fn from_value(value: &'a glib::Value) -> Self {
        from_glib(glib::gobject_ffi::g_value_get_enum(value.to_glib_none().0))
    }
}

impl ToValue for ElemIfaceType {
    fn to_value(&self) -> glib::Value {
        let mut value = glib::Value::for_value_type::<Self>();
        unsafe {
            glib::gobject_ffi::g_value_set_enum(value.to_glib_none_mut().0, self.into_glib());
        }
        value
    }

    fn value_type(&self) -> glib::Type {
        Self::static_type()
    }
}

#[derive(Debug, Eq, PartialEq, Ord, PartialOrd, Hash, Clone, Copy)]
#[non_exhaustive]
#[doc(alias = "ALSACtlElemType")]
pub enum ElemType {
    #[doc(alias = "ALSACTL_ELEM_TYPE_NONE")]
    None,
    #[doc(alias = "ALSACTL_ELEM_TYPE_BOOLEAN")]
    Boolean,
    #[doc(alias = "ALSACTL_ELEM_TYPE_INTEGER")]
    Integer,
    #[doc(alias = "ALSACTL_ELEM_TYPE_ENUMERATED")]
    Enumerated,
    #[doc(alias = "ALSACTL_ELEM_TYPE_BYTES")]
    Bytes,
    #[doc(alias = "ALSACTL_ELEM_TYPE_IEC60958")]
    Iec60958,
    #[doc(alias = "ALSACTL_ELEM_TYPE_INTEGER64")]
    Integer64,
    #[doc(hidden)]
    __Unknown(i32),
}

impl fmt::Display for ElemType {
    fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
        write!(
            f,
            "ElemType::{}",
            match *self {
                Self::None => "None",
                Self::Boolean => "Boolean",
                Self::Integer => "Integer",
                Self::Enumerated => "Enumerated",
                Self::Bytes => "Bytes",
                Self::Iec60958 => "Iec60958",
                Self::Integer64 => "Integer64",
                _ => "Unknown",
            }
        )
    }
}

#[doc(hidden)]
impl IntoGlib for ElemType {
    type GlibType = ffi::ALSACtlElemType;

    fn into_glib(self) -> ffi::ALSACtlElemType {
        match self {
            Self::None => ffi::ALSACTL_ELEM_TYPE_NONE,
            Self::Boolean => ffi::ALSACTL_ELEM_TYPE_BOOLEAN,
            Self::Integer => ffi::ALSACTL_ELEM_TYPE_INTEGER,
            Self::Enumerated => ffi::ALSACTL_ELEM_TYPE_ENUMERATED,
            Self::Bytes => ffi::ALSACTL_ELEM_TYPE_BYTES,
            Self::Iec60958 => ffi::ALSACTL_ELEM_TYPE_IEC60958,
            Self::Integer64 => ffi::ALSACTL_ELEM_TYPE_INTEGER64,
            Self::__Unknown(value) => value,
        }
    }
}

#[doc(hidden)]
impl FromGlib<ffi::ALSACtlElemType> for ElemType {
    unsafe fn from_glib(value: ffi::ALSACtlElemType) -> Self {
        match value {
            ffi::ALSACTL_ELEM_TYPE_NONE => Self::None,
            ffi::ALSACTL_ELEM_TYPE_BOOLEAN => Self::Boolean,
            ffi::ALSACTL_ELEM_TYPE_INTEGER => Self::Integer,
            ffi::ALSACTL_ELEM_TYPE_ENUMERATED => Self::Enumerated,
            ffi::ALSACTL_ELEM_TYPE_BYTES => Self::Bytes,
            ffi::ALSACTL_ELEM_TYPE_IEC60958 => Self::Iec60958,
            ffi::ALSACTL_ELEM_TYPE_INTEGER64 => Self::Integer64,
            value => Self::__Unknown(value),
        }
    }
}

impl StaticType for ElemType {
    fn static_type() -> Type {
        unsafe { from_glib(ffi::alsactl_elem_type_get_type()) }
    }
}

impl glib::value::ValueType for ElemType {
    type Type = Self;
}

unsafe impl<'a> FromValue<'a> for ElemType {
    type Checker = glib::value::GenericValueTypeChecker<Self>;

    unsafe fn from_value(value: &'a glib::Value) -> Self {
        from_glib(glib::gobject_ffi::g_value_get_enum(value.to_glib_none().0))
    }
}

impl ToValue for ElemType {
    fn to_value(&self) -> glib::Value {
        let mut value = glib::Value::for_value_type::<Self>();
        unsafe {
            glib::gobject_ffi::g_value_set_enum(value.to_glib_none_mut().0, self.into_glib());
        }
        value
    }

    fn value_type(&self) -> glib::Type {
        Self::static_type()
    }
}

#[derive(Debug, Eq, PartialEq, Ord, PartialOrd, Hash, Clone, Copy)]
#[non_exhaustive]
#[doc(alias = "ALSACtlEventType")]
pub enum EventType {
    #[doc(alias = "ALSACTL_EVENT_TYPE_ELEM")]
    Elem,
    #[doc(hidden)]
    __Unknown(i32),
}

impl fmt::Display for EventType {
    fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
        write!(
            f,
            "EventType::{}",
            match *self {
                Self::Elem => "Elem",
                _ => "Unknown",
            }
        )
    }
}

#[doc(hidden)]
impl IntoGlib for EventType {
    type GlibType = ffi::ALSACtlEventType;

    fn into_glib(self) -> ffi::ALSACtlEventType {
        match self {
            Self::Elem => ffi::ALSACTL_EVENT_TYPE_ELEM,
            Self::__Unknown(value) => value,
        }
    }
}

#[doc(hidden)]
impl FromGlib<ffi::ALSACtlEventType> for EventType {
    unsafe fn from_glib(value: ffi::ALSACtlEventType) -> Self {
        match value {
            ffi::ALSACTL_EVENT_TYPE_ELEM => Self::Elem,
            value => Self::__Unknown(value),
        }
    }
}

impl StaticType for EventType {
    fn static_type() -> Type {
        unsafe { from_glib(ffi::alsactl_event_type_get_type()) }
    }
}

impl glib::value::ValueType for EventType {
    type Type = Self;
}

unsafe impl<'a> FromValue<'a> for EventType {
    type Checker = glib::value::GenericValueTypeChecker<Self>;

    unsafe fn from_value(value: &'a glib::Value) -> Self {
        from_glib(glib::gobject_ffi::g_value_get_enum(value.to_glib_none().0))
    }
}

impl ToValue for EventType {
    fn to_value(&self) -> glib::Value {
        let mut value = glib::Value::for_value_type::<Self>();
        unsafe {
            glib::gobject_ffi::g_value_set_enum(value.to_glib_none_mut().0, self.into_glib());
        }
        value
    }

    fn value_type(&self) -> glib::Type {
        Self::static_type()
    }
}
