// 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 crate::ffi;
use glib::{prelude::*, translate::*};

#[derive(Debug, Eq, PartialEq, Ord, PartialOrd, Hash, Clone, Copy)]
#[non_exhaustive]
#[doc(alias = "ShumateFileCacheError")]
pub enum FileCacheError {
    #[doc(alias = "SHUMATE_FILE_CACHE_ERROR_FAILED")]
    Failed,
    #[doc(hidden)]
    __Unknown(i32),
}

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

    #[inline]
    fn into_glib(self) -> ffi::ShumateFileCacheError {
        match self {
            Self::Failed => ffi::SHUMATE_FILE_CACHE_ERROR_FAILED,
            Self::__Unknown(value) => value,
        }
    }
}

#[doc(hidden)]
impl FromGlib<ffi::ShumateFileCacheError> for FileCacheError {
    #[inline]
    unsafe fn from_glib(value: ffi::ShumateFileCacheError) -> Self {
        skip_assert_initialized!();

        match value {
            ffi::SHUMATE_FILE_CACHE_ERROR_FAILED => Self::Failed,
            value => Self::__Unknown(value),
        }
    }
}

impl glib::error::ErrorDomain for FileCacheError {
    #[inline]
    fn domain() -> glib::Quark {
        skip_assert_initialized!();

        unsafe { from_glib(ffi::shumate_file_cache_error_quark()) }
    }

    #[inline]
    fn code(self) -> i32 {
        self.into_glib()
    }

    #[inline]
    #[allow(clippy::match_single_binding)]
    fn from(code: i32) -> Option<Self> {
        skip_assert_initialized!();
        match unsafe { from_glib(code) } {
            Self::__Unknown(_) => Some(Self::Failed),
            value => Some(value),
        }
    }
}

impl StaticType for FileCacheError {
    #[inline]
    #[doc(alias = "shumate_file_cache_error_get_type")]
    fn static_type() -> glib::Type {
        unsafe { from_glib(ffi::shumate_file_cache_error_get_type()) }
    }
}

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

    fn param_spec_builder() -> Self::BuilderFn {
        Self::ParamSpec::builder_with_default
    }
}

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

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

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

impl ToValue for FileCacheError {
    #[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<FileCacheError> for glib::Value {
    #[inline]
    fn from(v: FileCacheError) -> Self {
        skip_assert_initialized!();
        ToValue::to_value(&v)
    }
}

#[cfg(feature = "v1_2")]
#[cfg_attr(docsrs, doc(cfg(feature = "v1_2")))]
#[derive(Debug, Eq, PartialEq, Ord, PartialOrd, Hash, Clone, Copy)]
#[non_exhaustive]
#[doc(alias = "ShumateGeometryType")]
pub enum GeometryType {
    #[doc(alias = "SHUMATE_GEOMETRY_TYPE_UNKNOWN")]
    Unknown,
    #[doc(alias = "SHUMATE_GEOMETRY_TYPE_POINT")]
    Point,
    #[doc(alias = "SHUMATE_GEOMETRY_TYPE_MULTIPOINT")]
    Multipoint,
    #[doc(alias = "SHUMATE_GEOMETRY_TYPE_LINESTRING")]
    Linestring,
    #[doc(alias = "SHUMATE_GEOMETRY_TYPE_MULTILINESTRING")]
    Multilinestring,
    #[doc(alias = "SHUMATE_GEOMETRY_TYPE_POLYGON")]
    Polygon,
    #[doc(alias = "SHUMATE_GEOMETRY_TYPE_MULTIPOLYGON")]
    Multipolygon,
    #[doc(hidden)]
    __Unknown(i32),
}

#[cfg(feature = "v1_2")]
#[cfg_attr(docsrs, doc(cfg(feature = "v1_2")))]
#[doc(hidden)]
impl IntoGlib for GeometryType {
    type GlibType = ffi::ShumateGeometryType;

    #[inline]
    fn into_glib(self) -> ffi::ShumateGeometryType {
        match self {
            Self::Unknown => ffi::SHUMATE_GEOMETRY_TYPE_UNKNOWN,
            Self::Point => ffi::SHUMATE_GEOMETRY_TYPE_POINT,
            Self::Multipoint => ffi::SHUMATE_GEOMETRY_TYPE_MULTIPOINT,
            Self::Linestring => ffi::SHUMATE_GEOMETRY_TYPE_LINESTRING,
            Self::Multilinestring => ffi::SHUMATE_GEOMETRY_TYPE_MULTILINESTRING,
            Self::Polygon => ffi::SHUMATE_GEOMETRY_TYPE_POLYGON,
            Self::Multipolygon => ffi::SHUMATE_GEOMETRY_TYPE_MULTIPOLYGON,
            Self::__Unknown(value) => value,
        }
    }
}

#[cfg(feature = "v1_2")]
#[cfg_attr(docsrs, doc(cfg(feature = "v1_2")))]
#[doc(hidden)]
impl FromGlib<ffi::ShumateGeometryType> for GeometryType {
    #[inline]
    unsafe fn from_glib(value: ffi::ShumateGeometryType) -> Self {
        skip_assert_initialized!();

        match value {
            ffi::SHUMATE_GEOMETRY_TYPE_UNKNOWN => Self::Unknown,
            ffi::SHUMATE_GEOMETRY_TYPE_POINT => Self::Point,
            ffi::SHUMATE_GEOMETRY_TYPE_MULTIPOINT => Self::Multipoint,
            ffi::SHUMATE_GEOMETRY_TYPE_LINESTRING => Self::Linestring,
            ffi::SHUMATE_GEOMETRY_TYPE_MULTILINESTRING => Self::Multilinestring,
            ffi::SHUMATE_GEOMETRY_TYPE_POLYGON => Self::Polygon,
            ffi::SHUMATE_GEOMETRY_TYPE_MULTIPOLYGON => Self::Multipolygon,
            value => Self::__Unknown(value),
        }
    }
}

#[cfg(feature = "v1_2")]
#[cfg_attr(docsrs, doc(cfg(feature = "v1_2")))]
impl StaticType for GeometryType {
    #[inline]
    #[doc(alias = "shumate_geometry_type_get_type")]
    fn static_type() -> glib::Type {
        unsafe { from_glib(ffi::shumate_geometry_type_get_type()) }
    }
}

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

    fn param_spec_builder() -> Self::BuilderFn {
        Self::ParamSpec::builder_with_default
    }
}

#[cfg(feature = "v1_2")]
#[cfg_attr(docsrs, doc(cfg(feature = "v1_2")))]
impl glib::value::ValueType for GeometryType {
    type Type = Self;
}

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

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

#[cfg(feature = "v1_2")]
#[cfg_attr(docsrs, doc(cfg(feature = "v1_2")))]
impl ToValue for GeometryType {
    #[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(feature = "v1_2")]
#[cfg_attr(docsrs, doc(cfg(feature = "v1_2")))]
impl From<GeometryType> for glib::Value {
    #[inline]
    fn from(v: GeometryType) -> Self {
        skip_assert_initialized!();
        ToValue::to_value(&v)
    }
}

#[derive(Debug, Eq, PartialEq, Ord, PartialOrd, Hash, Clone, Copy)]
#[non_exhaustive]
#[doc(alias = "ShumateMapProjection")]
pub enum MapProjection {
    #[doc(alias = "SHUMATE_MAP_PROJECTION_MERCATOR")]
    Mercator,
    #[doc(hidden)]
    __Unknown(i32),
}

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

    #[inline]
    fn into_glib(self) -> ffi::ShumateMapProjection {
        match self {
            Self::Mercator => ffi::SHUMATE_MAP_PROJECTION_MERCATOR,
            Self::__Unknown(value) => value,
        }
    }
}

#[doc(hidden)]
impl FromGlib<ffi::ShumateMapProjection> for MapProjection {
    #[inline]
    unsafe fn from_glib(value: ffi::ShumateMapProjection) -> Self {
        skip_assert_initialized!();

        match value {
            ffi::SHUMATE_MAP_PROJECTION_MERCATOR => Self::Mercator,
            value => Self::__Unknown(value),
        }
    }
}

impl StaticType for MapProjection {
    #[inline]
    #[doc(alias = "shumate_map_projection_get_type")]
    fn static_type() -> glib::Type {
        unsafe { from_glib(ffi::shumate_map_projection_get_type()) }
    }
}

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

    fn param_spec_builder() -> Self::BuilderFn {
        Self::ParamSpec::builder_with_default
    }
}

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

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

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

impl ToValue for MapProjection {
    #[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<MapProjection> for glib::Value {
    #[inline]
    fn from(v: MapProjection) -> Self {
        skip_assert_initialized!();
        ToValue::to_value(&v)
    }
}

#[derive(Debug, Eq, PartialEq, Ord, PartialOrd, Hash, Clone, Copy)]
#[non_exhaustive]
#[doc(alias = "ShumateState")]
pub enum State {
    #[doc(alias = "SHUMATE_STATE_NONE")]
    None,
    #[doc(alias = "SHUMATE_STATE_LOADING")]
    Loading,
    #[doc(alias = "SHUMATE_STATE_LOADED")]
    Loaded,
    #[doc(alias = "SHUMATE_STATE_DONE")]
    Done,
    #[doc(hidden)]
    __Unknown(i32),
}

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

    #[inline]
    fn into_glib(self) -> ffi::ShumateState {
        match self {
            Self::None => ffi::SHUMATE_STATE_NONE,
            Self::Loading => ffi::SHUMATE_STATE_LOADING,
            Self::Loaded => ffi::SHUMATE_STATE_LOADED,
            Self::Done => ffi::SHUMATE_STATE_DONE,
            Self::__Unknown(value) => value,
        }
    }
}

#[doc(hidden)]
impl FromGlib<ffi::ShumateState> for State {
    #[inline]
    unsafe fn from_glib(value: ffi::ShumateState) -> Self {
        skip_assert_initialized!();

        match value {
            ffi::SHUMATE_STATE_NONE => Self::None,
            ffi::SHUMATE_STATE_LOADING => Self::Loading,
            ffi::SHUMATE_STATE_LOADED => Self::Loaded,
            ffi::SHUMATE_STATE_DONE => Self::Done,
            value => Self::__Unknown(value),
        }
    }
}

impl StaticType for State {
    #[inline]
    #[doc(alias = "shumate_state_get_type")]
    fn static_type() -> glib::Type {
        unsafe { from_glib(ffi::shumate_state_get_type()) }
    }
}

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

    fn param_spec_builder() -> Self::BuilderFn {
        Self::ParamSpec::builder_with_default
    }
}

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

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

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

impl ToValue for State {
    #[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<State> for glib::Value {
    #[inline]
    fn from(v: State) -> Self {
        skip_assert_initialized!();
        ToValue::to_value(&v)
    }
}

#[derive(Debug, Eq, PartialEq, Ord, PartialOrd, Hash, Clone, Copy)]
#[non_exhaustive]
#[doc(alias = "ShumateStyleError")]
pub enum StyleError {
    #[doc(alias = "SHUMATE_STYLE_ERROR_FAILED")]
    Failed,
    #[doc(alias = "SHUMATE_STYLE_ERROR_MALFORMED_STYLE")]
    MalformedStyle,
    #[doc(alias = "SHUMATE_STYLE_ERROR_UNSUPPORTED_LAYER")]
    UnsupportedLayer,
    #[doc(alias = "SHUMATE_STYLE_ERROR_INVALID_EXPRESSION")]
    InvalidExpression,
    #[doc(alias = "SHUMATE_STYLE_ERROR_SUPPORT_OMITTED")]
    SupportOmitted,
    #[doc(alias = "SHUMATE_STYLE_ERROR_UNSUPPORTED")]
    Unsupported,
    #[doc(hidden)]
    __Unknown(i32),
}

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

    #[inline]
    fn into_glib(self) -> ffi::ShumateStyleError {
        match self {
            Self::Failed => ffi::SHUMATE_STYLE_ERROR_FAILED,
            Self::MalformedStyle => ffi::SHUMATE_STYLE_ERROR_MALFORMED_STYLE,
            Self::UnsupportedLayer => ffi::SHUMATE_STYLE_ERROR_UNSUPPORTED_LAYER,
            Self::InvalidExpression => ffi::SHUMATE_STYLE_ERROR_INVALID_EXPRESSION,
            Self::SupportOmitted => ffi::SHUMATE_STYLE_ERROR_SUPPORT_OMITTED,
            Self::Unsupported => ffi::SHUMATE_STYLE_ERROR_UNSUPPORTED,
            Self::__Unknown(value) => value,
        }
    }
}

#[doc(hidden)]
impl FromGlib<ffi::ShumateStyleError> for StyleError {
    #[inline]
    unsafe fn from_glib(value: ffi::ShumateStyleError) -> Self {
        skip_assert_initialized!();

        match value {
            ffi::SHUMATE_STYLE_ERROR_FAILED => Self::Failed,
            ffi::SHUMATE_STYLE_ERROR_MALFORMED_STYLE => Self::MalformedStyle,
            ffi::SHUMATE_STYLE_ERROR_UNSUPPORTED_LAYER => Self::UnsupportedLayer,
            ffi::SHUMATE_STYLE_ERROR_INVALID_EXPRESSION => Self::InvalidExpression,
            ffi::SHUMATE_STYLE_ERROR_SUPPORT_OMITTED => Self::SupportOmitted,
            ffi::SHUMATE_STYLE_ERROR_UNSUPPORTED => Self::Unsupported,
            value => Self::__Unknown(value),
        }
    }
}

impl glib::error::ErrorDomain for StyleError {
    #[inline]
    fn domain() -> glib::Quark {
        skip_assert_initialized!();

        unsafe { from_glib(ffi::shumate_style_error_quark()) }
    }

    #[inline]
    fn code(self) -> i32 {
        self.into_glib()
    }

    #[inline]
    #[allow(clippy::match_single_binding)]
    fn from(code: i32) -> Option<Self> {
        skip_assert_initialized!();
        match unsafe { from_glib(code) } {
            Self::__Unknown(_) => Some(Self::Failed),
            value => Some(value),
        }
    }
}

impl StaticType for StyleError {
    #[inline]
    #[doc(alias = "shumate_style_error_get_type")]
    fn static_type() -> glib::Type {
        unsafe { from_glib(ffi::shumate_style_error_get_type()) }
    }
}

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

    fn param_spec_builder() -> Self::BuilderFn {
        Self::ParamSpec::builder_with_default
    }
}

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

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

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

impl ToValue for StyleError {
    #[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<StyleError> for glib::Value {
    #[inline]
    fn from(v: StyleError) -> Self {
        skip_assert_initialized!();
        ToValue::to_value(&v)
    }
}

#[derive(Debug, Eq, PartialEq, Ord, PartialOrd, Hash, Clone, Copy)]
#[non_exhaustive]
#[doc(alias = "ShumateTileDownloaderError")]
pub enum TileDownloaderError {
    #[doc(alias = "SHUMATE_TILE_DOWNLOADER_ERROR_FAILED")]
    Failed,
    #[doc(alias = "SHUMATE_TILE_DOWNLOADER_ERROR_BAD_RESPONSE")]
    BadResponse,
    #[doc(alias = "SHUMATE_TILE_DOWNLOADER_ERROR_COULD_NOT_CONNECT")]
    CouldNotConnect,
    #[doc(alias = "SHUMATE_TILE_DOWNLOADER_ERROR_MALFORMED_URL")]
    MalformedUrl,
    #[doc(alias = "SHUMATE_TILE_DOWNLOADER_ERROR_OFFLINE")]
    Offline,
    #[doc(hidden)]
    __Unknown(i32),
}

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

    #[inline]
    fn into_glib(self) -> ffi::ShumateTileDownloaderError {
        match self {
            Self::Failed => ffi::SHUMATE_TILE_DOWNLOADER_ERROR_FAILED,
            Self::BadResponse => ffi::SHUMATE_TILE_DOWNLOADER_ERROR_BAD_RESPONSE,
            Self::CouldNotConnect => ffi::SHUMATE_TILE_DOWNLOADER_ERROR_COULD_NOT_CONNECT,
            Self::MalformedUrl => ffi::SHUMATE_TILE_DOWNLOADER_ERROR_MALFORMED_URL,
            Self::Offline => ffi::SHUMATE_TILE_DOWNLOADER_ERROR_OFFLINE,
            Self::__Unknown(value) => value,
        }
    }
}

#[doc(hidden)]
impl FromGlib<ffi::ShumateTileDownloaderError> for TileDownloaderError {
    #[inline]
    unsafe fn from_glib(value: ffi::ShumateTileDownloaderError) -> Self {
        skip_assert_initialized!();

        match value {
            ffi::SHUMATE_TILE_DOWNLOADER_ERROR_FAILED => Self::Failed,
            ffi::SHUMATE_TILE_DOWNLOADER_ERROR_BAD_RESPONSE => Self::BadResponse,
            ffi::SHUMATE_TILE_DOWNLOADER_ERROR_COULD_NOT_CONNECT => Self::CouldNotConnect,
            ffi::SHUMATE_TILE_DOWNLOADER_ERROR_MALFORMED_URL => Self::MalformedUrl,
            ffi::SHUMATE_TILE_DOWNLOADER_ERROR_OFFLINE => Self::Offline,
            value => Self::__Unknown(value),
        }
    }
}

impl glib::error::ErrorDomain for TileDownloaderError {
    #[inline]
    fn domain() -> glib::Quark {
        skip_assert_initialized!();

        unsafe { from_glib(ffi::shumate_tile_downloader_error_quark()) }
    }

    #[inline]
    fn code(self) -> i32 {
        self.into_glib()
    }

    #[inline]
    #[allow(clippy::match_single_binding)]
    fn from(code: i32) -> Option<Self> {
        skip_assert_initialized!();
        match unsafe { from_glib(code) } {
            Self::__Unknown(_) => Some(Self::Failed),
            value => Some(value),
        }
    }
}

impl StaticType for TileDownloaderError {
    #[inline]
    #[doc(alias = "shumate_tile_downloader_error_get_type")]
    fn static_type() -> glib::Type {
        unsafe { from_glib(ffi::shumate_tile_downloader_error_get_type()) }
    }
}

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

    fn param_spec_builder() -> Self::BuilderFn {
        Self::ParamSpec::builder_with_default
    }
}

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

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

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

impl ToValue for TileDownloaderError {
    #[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<TileDownloaderError> for glib::Value {
    #[inline]
    fn from(v: TileDownloaderError) -> Self {
        skip_assert_initialized!();
        ToValue::to_value(&v)
    }
}

#[derive(Debug, Eq, PartialEq, Ord, PartialOrd, Hash, Clone, Copy)]
#[non_exhaustive]
#[doc(alias = "ShumateUnit")]
pub enum Unit {
    #[doc(alias = "SHUMATE_UNIT_BOTH")]
    Both,
    #[doc(alias = "SHUMATE_UNIT_METRIC")]
    Metric,
    #[doc(alias = "SHUMATE_UNIT_IMPERIAL")]
    Imperial,
    #[doc(hidden)]
    __Unknown(i32),
}

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

    #[inline]
    fn into_glib(self) -> ffi::ShumateUnit {
        match self {
            Self::Both => ffi::SHUMATE_UNIT_BOTH,
            Self::Metric => ffi::SHUMATE_UNIT_METRIC,
            Self::Imperial => ffi::SHUMATE_UNIT_IMPERIAL,
            Self::__Unknown(value) => value,
        }
    }
}

#[doc(hidden)]
impl FromGlib<ffi::ShumateUnit> for Unit {
    #[inline]
    unsafe fn from_glib(value: ffi::ShumateUnit) -> Self {
        skip_assert_initialized!();

        match value {
            ffi::SHUMATE_UNIT_BOTH => Self::Both,
            ffi::SHUMATE_UNIT_METRIC => Self::Metric,
            ffi::SHUMATE_UNIT_IMPERIAL => Self::Imperial,
            value => Self::__Unknown(value),
        }
    }
}

impl StaticType for Unit {
    #[inline]
    #[doc(alias = "shumate_unit_get_type")]
    fn static_type() -> glib::Type {
        unsafe { from_glib(ffi::shumate_unit_get_type()) }
    }
}

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

    fn param_spec_builder() -> Self::BuilderFn {
        Self::ParamSpec::builder_with_default
    }
}

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

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

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

impl ToValue for Unit {
    #[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<Unit> for glib::Value {
    #[inline]
    fn from(v: Unit) -> Self {
        skip_assert_initialized!();
        ToValue::to_value(&v)
    }
}
