1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
// This file was generated by gir (7504fb6) from gir-files (71d73f0)
// DO NOT EDIT

use ffi;
use ffi as glib_ffi;
use error::ErrorDomain;
use translate::*;
use std;

#[derive(Clone, Copy, Debug, Eq, PartialEq, Hash)]
pub enum KeyFileError {
    UnknownEncoding,
    Parse,
    NotFound,
    KeyNotFound,
    GroupNotFound,
    InvalidValue,
    #[doc(hidden)]
    __Unknown(i32),
}

#[doc(hidden)]
impl ToGlib for KeyFileError {
    type GlibType = ffi::GKeyFileError;

    fn to_glib(&self) -> ffi::GKeyFileError {
        match *self {
            KeyFileError::UnknownEncoding => ffi::G_KEY_FILE_ERROR_UNKNOWN_ENCODING,
            KeyFileError::Parse => ffi::G_KEY_FILE_ERROR_PARSE,
            KeyFileError::NotFound => ffi::G_KEY_FILE_ERROR_NOT_FOUND,
            KeyFileError::KeyNotFound => ffi::G_KEY_FILE_ERROR_KEY_NOT_FOUND,
            KeyFileError::GroupNotFound => ffi::G_KEY_FILE_ERROR_GROUP_NOT_FOUND,
            KeyFileError::InvalidValue => ffi::G_KEY_FILE_ERROR_INVALID_VALUE,
            KeyFileError::__Unknown(value) => unsafe{std::mem::transmute(value)}
        }
    }
}

#[doc(hidden)]
impl FromGlib<ffi::GKeyFileError> for KeyFileError {
    fn from_glib(value: ffi::GKeyFileError) -> Self {
        match value as i32 {
            0 => KeyFileError::UnknownEncoding,
            1 => KeyFileError::Parse,
            2 => KeyFileError::NotFound,
            3 => KeyFileError::KeyNotFound,
            4 => KeyFileError::GroupNotFound,
            5 => KeyFileError::InvalidValue,
            value => KeyFileError::__Unknown(value),
        }
    }
}

impl ErrorDomain for KeyFileError {
    fn domain() -> glib_ffi::GQuark {
        unsafe { ffi::g_key_file_error_quark() }
    }

    fn code(self) -> i32 {
        self.to_glib() as i32
    }

    fn from(code: i32) -> Option<Self> {
        match code {
            0 => Some(KeyFileError::UnknownEncoding),
            1 => Some(KeyFileError::Parse),
            2 => Some(KeyFileError::NotFound),
            3 => Some(KeyFileError::KeyNotFound),
            4 => Some(KeyFileError::GroupNotFound),
            5 => Some(KeyFileError::InvalidValue),
            value => Some(KeyFileError::__Unknown(value)),
        }
    }
}