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

use glib::{translate::*, value::FromValue, value::ToValue, StaticType, Type};
use std::fmt;

#[cfg(any(feature = "v0_19", feature = "dox"))]
#[cfg_attr(feature = "dox", doc(cfg(feature = "v0_19")))]
#[derive(Debug, Eq, PartialEq, Ord, PartialOrd, Hash, Clone, Copy)]
#[non_exhaustive]
#[doc(alias = "SecretBackendFlags")]
pub enum BackendFlags {
    #[doc(alias = "SECRET_BACKEND_NONE")]
    None,
    #[doc(alias = "SECRET_BACKEND_OPEN_SESSION")]
    OpenSession,
    #[doc(alias = "SECRET_BACKEND_LOAD_COLLECTIONS")]
    LoadCollections,
    #[doc(hidden)]
    __Unknown(i32),
}

#[cfg(any(feature = "v0_19", feature = "dox"))]
#[cfg_attr(feature = "dox", doc(cfg(feature = "v0_19")))]
impl fmt::Display for BackendFlags {
    fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
        write!(
            f,
            "BackendFlags::{}",
            match *self {
                Self::None => "None",
                Self::OpenSession => "OpenSession",
                Self::LoadCollections => "LoadCollections",
                _ => "Unknown",
            }
        )
    }
}

#[cfg(any(feature = "v0_19", feature = "dox"))]
#[cfg_attr(feature = "dox", doc(cfg(feature = "v0_19")))]
#[doc(hidden)]
impl IntoGlib for BackendFlags {
    type GlibType = ffi::SecretBackendFlags;

    #[inline]
    fn into_glib(self) -> ffi::SecretBackendFlags {
        match self {
            Self::None => ffi::SECRET_BACKEND_NONE,
            Self::OpenSession => ffi::SECRET_BACKEND_OPEN_SESSION,
            Self::LoadCollections => ffi::SECRET_BACKEND_LOAD_COLLECTIONS,
            Self::__Unknown(value) => value,
        }
    }
}

#[cfg(any(feature = "v0_19", feature = "dox"))]
#[cfg_attr(feature = "dox", doc(cfg(feature = "v0_19")))]
#[doc(hidden)]
impl FromGlib<ffi::SecretBackendFlags> for BackendFlags {
    #[inline]
    unsafe fn from_glib(value: ffi::SecretBackendFlags) -> Self {
        match value {
            ffi::SECRET_BACKEND_NONE => Self::None,
            ffi::SECRET_BACKEND_OPEN_SESSION => Self::OpenSession,
            ffi::SECRET_BACKEND_LOAD_COLLECTIONS => Self::LoadCollections,
            value => Self::__Unknown(value),
        }
    }
}

#[cfg(any(feature = "v0_19", feature = "dox"))]
#[cfg_attr(feature = "dox", doc(cfg(feature = "v0_19")))]
impl StaticType for BackendFlags {
    #[inline]
    fn static_type() -> Type {
        unsafe { from_glib(ffi::secret_backend_flags_get_type()) }
    }
}

#[cfg(any(feature = "v0_19", feature = "dox"))]
#[cfg_attr(feature = "dox", doc(cfg(feature = "v0_19")))]
impl glib::HasParamSpec for BackendFlags {
    type ParamSpec = glib::ParamSpecEnum;
    type SetValue = Self;
    type BuilderFn = fn(&str, Self) -> glib::ParamSpecEnumBuilder<Self>;

    fn param_spec_builder() -> Self::BuilderFn {
        |name, default_value| Self::ParamSpec::builder_with_default(name, default_value)
    }
}

#[cfg(any(feature = "v0_19", feature = "dox"))]
#[cfg_attr(feature = "dox", doc(cfg(feature = "v0_19")))]
impl glib::value::ValueType for BackendFlags {
    type Type = Self;
}

#[cfg(any(feature = "v0_19", feature = "dox"))]
#[cfg_attr(feature = "dox", doc(cfg(feature = "v0_19")))]
unsafe impl<'a> FromValue<'a> for BackendFlags {
    type Checker = glib::value::GenericValueTypeChecker<Self>;

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

#[cfg(any(feature = "v0_19", feature = "dox"))]
#[cfg_attr(feature = "dox", doc(cfg(feature = "v0_19")))]
impl ToValue for BackendFlags {
    #[inline]
    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
    }

    #[inline]
    fn value_type(&self) -> glib::Type {
        Self::static_type()
    }
}

#[cfg(any(feature = "v0_19", feature = "dox"))]
#[cfg_attr(feature = "dox", doc(cfg(feature = "v0_19")))]
impl From<BackendFlags> for glib::Value {
    #[inline]
    fn from(v: BackendFlags) -> Self {
        ToValue::to_value(&v)
    }
}

#[derive(Debug, Eq, PartialEq, Ord, PartialOrd, Hash, Clone, Copy)]
#[non_exhaustive]
#[doc(alias = "SecretError")]
pub enum Error {
    #[doc(alias = "SECRET_ERROR_PROTOCOL")]
    Protocol,
    #[doc(alias = "SECRET_ERROR_IS_LOCKED")]
    IsLocked,
    #[doc(alias = "SECRET_ERROR_NO_SUCH_OBJECT")]
    NoSuchObject,
    #[doc(alias = "SECRET_ERROR_ALREADY_EXISTS")]
    AlreadyExists,
    #[doc(alias = "SECRET_ERROR_INVALID_FILE_FORMAT")]
    InvalidFileFormat,
    #[doc(hidden)]
    __Unknown(i32),
}

impl fmt::Display for Error {
    fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
        write!(
            f,
            "Error::{}",
            match *self {
                Self::Protocol => "Protocol",
                Self::IsLocked => "IsLocked",
                Self::NoSuchObject => "NoSuchObject",
                Self::AlreadyExists => "AlreadyExists",
                Self::InvalidFileFormat => "InvalidFileFormat",
                _ => "Unknown",
            }
        )
    }
}

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

    #[inline]
    fn into_glib(self) -> ffi::SecretError {
        match self {
            Self::Protocol => ffi::SECRET_ERROR_PROTOCOL,
            Self::IsLocked => ffi::SECRET_ERROR_IS_LOCKED,
            Self::NoSuchObject => ffi::SECRET_ERROR_NO_SUCH_OBJECT,
            Self::AlreadyExists => ffi::SECRET_ERROR_ALREADY_EXISTS,
            Self::InvalidFileFormat => ffi::SECRET_ERROR_INVALID_FILE_FORMAT,
            Self::__Unknown(value) => value,
        }
    }
}

#[doc(hidden)]
impl FromGlib<ffi::SecretError> for Error {
    #[inline]
    unsafe fn from_glib(value: ffi::SecretError) -> Self {
        match value {
            ffi::SECRET_ERROR_PROTOCOL => Self::Protocol,
            ffi::SECRET_ERROR_IS_LOCKED => Self::IsLocked,
            ffi::SECRET_ERROR_NO_SUCH_OBJECT => Self::NoSuchObject,
            ffi::SECRET_ERROR_ALREADY_EXISTS => Self::AlreadyExists,
            ffi::SECRET_ERROR_INVALID_FILE_FORMAT => Self::InvalidFileFormat,
            value => Self::__Unknown(value),
        }
    }
}

impl StaticType for Error {
    #[inline]
    fn static_type() -> Type {
        unsafe { from_glib(ffi::secret_error_get_type()) }
    }
}

impl glib::HasParamSpec for Error {
    type ParamSpec = glib::ParamSpecEnum;
    type SetValue = Self;
    type BuilderFn = fn(&str, Self) -> glib::ParamSpecEnumBuilder<Self>;

    fn param_spec_builder() -> Self::BuilderFn {
        |name, default_value| Self::ParamSpec::builder_with_default(name, default_value)
    }
}

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

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

    #[inline]
    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 Error {
    #[inline]
    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
    }

    #[inline]
    fn value_type(&self) -> glib::Type {
        Self::static_type()
    }
}

impl From<Error> for glib::Value {
    #[inline]
    fn from(v: Error) -> Self {
        ToValue::to_value(&v)
    }
}

#[derive(Debug, Eq, PartialEq, Ord, PartialOrd, Hash, Clone, Copy)]
#[non_exhaustive]
#[doc(alias = "SecretSchemaAttributeType")]
pub enum SchemaAttributeType {
    #[doc(alias = "SECRET_SCHEMA_ATTRIBUTE_STRING")]
    String,
    #[doc(alias = "SECRET_SCHEMA_ATTRIBUTE_INTEGER")]
    Integer,
    #[doc(alias = "SECRET_SCHEMA_ATTRIBUTE_BOOLEAN")]
    Boolean,
    #[doc(hidden)]
    __Unknown(i32),
}

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

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

    #[inline]
    fn into_glib(self) -> ffi::SecretSchemaAttributeType {
        match self {
            Self::String => ffi::SECRET_SCHEMA_ATTRIBUTE_STRING,
            Self::Integer => ffi::SECRET_SCHEMA_ATTRIBUTE_INTEGER,
            Self::Boolean => ffi::SECRET_SCHEMA_ATTRIBUTE_BOOLEAN,
            Self::__Unknown(value) => value,
        }
    }
}

#[doc(hidden)]
impl FromGlib<ffi::SecretSchemaAttributeType> for SchemaAttributeType {
    #[inline]
    unsafe fn from_glib(value: ffi::SecretSchemaAttributeType) -> Self {
        match value {
            ffi::SECRET_SCHEMA_ATTRIBUTE_STRING => Self::String,
            ffi::SECRET_SCHEMA_ATTRIBUTE_INTEGER => Self::Integer,
            ffi::SECRET_SCHEMA_ATTRIBUTE_BOOLEAN => Self::Boolean,
            value => Self::__Unknown(value),
        }
    }
}

impl StaticType for SchemaAttributeType {
    #[inline]
    fn static_type() -> Type {
        unsafe { from_glib(ffi::secret_schema_attribute_type_get_type()) }
    }
}

impl glib::HasParamSpec for SchemaAttributeType {
    type ParamSpec = glib::ParamSpecEnum;
    type SetValue = Self;
    type BuilderFn = fn(&str, Self) -> glib::ParamSpecEnumBuilder<Self>;

    fn param_spec_builder() -> Self::BuilderFn {
        |name, default_value| Self::ParamSpec::builder_with_default(name, default_value)
    }
}

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

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

    #[inline]
    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 SchemaAttributeType {
    #[inline]
    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
    }

    #[inline]
    fn value_type(&self) -> glib::Type {
        Self::static_type()
    }
}

impl From<SchemaAttributeType> for glib::Value {
    #[inline]
    fn from(v: SchemaAttributeType) -> Self {
        ToValue::to_value(&v)
    }
}

#[cfg(any(feature = "v0_18_6", feature = "dox"))]
#[cfg_attr(feature = "dox", doc(cfg(feature = "v0_18_6")))]
#[derive(Debug, Eq, PartialEq, Ord, PartialOrd, Hash, Clone, Copy)]
#[non_exhaustive]
#[doc(alias = "SecretSchemaType")]
pub enum SchemaType {
    #[doc(alias = "SECRET_SCHEMA_TYPE_NOTE")]
    Note,
    #[doc(alias = "SECRET_SCHEMA_TYPE_COMPAT_NETWORK")]
    CompatNetwork,
    #[doc(hidden)]
    __Unknown(i32),
}

#[cfg(any(feature = "v0_18_6", feature = "dox"))]
#[cfg_attr(feature = "dox", doc(cfg(feature = "v0_18_6")))]
impl fmt::Display for SchemaType {
    fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
        write!(
            f,
            "SchemaType::{}",
            match *self {
                Self::Note => "Note",
                Self::CompatNetwork => "CompatNetwork",
                _ => "Unknown",
            }
        )
    }
}

#[cfg(any(feature = "v0_18_6", feature = "dox"))]
#[cfg_attr(feature = "dox", doc(cfg(feature = "v0_18_6")))]
#[doc(hidden)]
impl IntoGlib for SchemaType {
    type GlibType = ffi::SecretSchemaType;

    #[inline]
    fn into_glib(self) -> ffi::SecretSchemaType {
        match self {
            Self::Note => ffi::SECRET_SCHEMA_TYPE_NOTE,
            Self::CompatNetwork => ffi::SECRET_SCHEMA_TYPE_COMPAT_NETWORK,
            Self::__Unknown(value) => value,
        }
    }
}

#[cfg(any(feature = "v0_18_6", feature = "dox"))]
#[cfg_attr(feature = "dox", doc(cfg(feature = "v0_18_6")))]
#[doc(hidden)]
impl FromGlib<ffi::SecretSchemaType> for SchemaType {
    #[inline]
    unsafe fn from_glib(value: ffi::SecretSchemaType) -> Self {
        match value {
            ffi::SECRET_SCHEMA_TYPE_NOTE => Self::Note,
            ffi::SECRET_SCHEMA_TYPE_COMPAT_NETWORK => Self::CompatNetwork,
            value => Self::__Unknown(value),
        }
    }
}

#[cfg(any(feature = "v0_18_6", feature = "dox"))]
#[cfg_attr(feature = "dox", doc(cfg(feature = "v0_18_6")))]
impl StaticType for SchemaType {
    #[inline]
    fn static_type() -> Type {
        unsafe { from_glib(ffi::secret_schema_type_get_type()) }
    }
}

#[cfg(any(feature = "v0_18_6", feature = "dox"))]
#[cfg_attr(feature = "dox", doc(cfg(feature = "v0_18_6")))]
impl glib::HasParamSpec for SchemaType {
    type ParamSpec = glib::ParamSpecEnum;
    type SetValue = Self;
    type BuilderFn = fn(&str, Self) -> glib::ParamSpecEnumBuilder<Self>;

    fn param_spec_builder() -> Self::BuilderFn {
        |name, default_value| Self::ParamSpec::builder_with_default(name, default_value)
    }
}

#[cfg(any(feature = "v0_18_6", feature = "dox"))]
#[cfg_attr(feature = "dox", doc(cfg(feature = "v0_18_6")))]
impl glib::value::ValueType for SchemaType {
    type Type = Self;
}

#[cfg(any(feature = "v0_18_6", feature = "dox"))]
#[cfg_attr(feature = "dox", doc(cfg(feature = "v0_18_6")))]
unsafe impl<'a> FromValue<'a> for SchemaType {
    type Checker = glib::value::GenericValueTypeChecker<Self>;

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

#[cfg(any(feature = "v0_18_6", feature = "dox"))]
#[cfg_attr(feature = "dox", doc(cfg(feature = "v0_18_6")))]
impl ToValue for SchemaType {
    #[inline]
    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
    }

    #[inline]
    fn value_type(&self) -> glib::Type {
        Self::static_type()
    }
}

#[cfg(any(feature = "v0_18_6", feature = "dox"))]
#[cfg_attr(feature = "dox", doc(cfg(feature = "v0_18_6")))]
impl From<SchemaType> for glib::Value {
    #[inline]
    fn from(v: SchemaType) -> Self {
        ToValue::to_value(&v)
    }
}
