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
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
use error::ErrorDomain;
use Quark;
use ffi as glib_ffi;
use translate::from_glib;
#[derive(Clone, Copy, Debug, PartialEq, Eq)]
pub enum FileError {
Exist,
Isdir,
Acces,
Nametoolong,
Noent,
Notdir,
Nxio,
Nodev,
Rofs,
Txtbsy,
Fault,
Loop,
Nospc,
Nomem,
Mfile,
Nfile,
Badf,
Inval,
Pipe,
Again,
Intr,
Io,
Perm,
Nosys,
Failed,
}
impl ErrorDomain for FileError {
fn domain() -> Quark {
unsafe { from_glib(glib_ffi::g_file_error_quark()) }
}
fn code(self) -> i32 {
use self::FileError::*;
match self {
Exist => glib_ffi::G_FILE_ERROR_EXIST as i32,
Isdir => glib_ffi::G_FILE_ERROR_ISDIR as i32,
Acces => glib_ffi::G_FILE_ERROR_ACCES as i32,
Nametoolong => glib_ffi::G_FILE_ERROR_NAMETOOLONG as i32,
Noent => glib_ffi::G_FILE_ERROR_NOENT as i32,
Notdir => glib_ffi::G_FILE_ERROR_NOTDIR as i32,
Nxio => glib_ffi::G_FILE_ERROR_NXIO as i32,
Nodev => glib_ffi::G_FILE_ERROR_NODEV as i32,
Rofs => glib_ffi::G_FILE_ERROR_ROFS as i32,
Txtbsy => glib_ffi::G_FILE_ERROR_TXTBSY as i32,
Fault => glib_ffi::G_FILE_ERROR_FAULT as i32,
Loop => glib_ffi::G_FILE_ERROR_LOOP as i32,
Nospc => glib_ffi::G_FILE_ERROR_NOSPC as i32,
Nomem => glib_ffi::G_FILE_ERROR_NOMEM as i32,
Mfile => glib_ffi::G_FILE_ERROR_MFILE as i32,
Nfile => glib_ffi::G_FILE_ERROR_NFILE as i32,
Badf => glib_ffi::G_FILE_ERROR_BADF as i32,
Inval => glib_ffi::G_FILE_ERROR_INVAL as i32,
Pipe => glib_ffi::G_FILE_ERROR_PIPE as i32,
Again => glib_ffi::G_FILE_ERROR_AGAIN as i32,
Intr => glib_ffi::G_FILE_ERROR_INTR as i32,
Io => glib_ffi::G_FILE_ERROR_IO as i32,
Perm => glib_ffi::G_FILE_ERROR_PERM as i32,
Nosys => glib_ffi::G_FILE_ERROR_NOSYS as i32,
Failed => glib_ffi::G_FILE_ERROR_FAILED as i32,
}
}
#[cfg_attr(feature = "cargo-clippy", allow(cyclomatic_complexity))]
fn from(code: i32) -> Option<Self> {
use self::FileError::*;
match code {
x if x == glib_ffi::G_FILE_ERROR_EXIST as i32 => Some(Exist),
x if x == glib_ffi::G_FILE_ERROR_ISDIR as i32 => Some(Isdir),
x if x == glib_ffi::G_FILE_ERROR_ACCES as i32 => Some(Acces),
x if x == glib_ffi::G_FILE_ERROR_NAMETOOLONG as i32 => Some(Nametoolong),
x if x == glib_ffi::G_FILE_ERROR_NOENT as i32 => Some(Noent),
x if x == glib_ffi::G_FILE_ERROR_NOTDIR as i32 => Some(Notdir),
x if x == glib_ffi::G_FILE_ERROR_NXIO as i32 => Some(Nxio),
x if x == glib_ffi::G_FILE_ERROR_NODEV as i32 => Some(Nodev),
x if x == glib_ffi::G_FILE_ERROR_ROFS as i32 => Some(Rofs),
x if x == glib_ffi::G_FILE_ERROR_TXTBSY as i32 => Some(Txtbsy),
x if x == glib_ffi::G_FILE_ERROR_FAULT as i32 => Some(Fault),
x if x == glib_ffi::G_FILE_ERROR_LOOP as i32 => Some(Loop),
x if x == glib_ffi::G_FILE_ERROR_NOSPC as i32 => Some(Nospc),
x if x == glib_ffi::G_FILE_ERROR_NOMEM as i32 => Some(Nomem),
x if x == glib_ffi::G_FILE_ERROR_MFILE as i32 => Some(Mfile),
x if x == glib_ffi::G_FILE_ERROR_NFILE as i32 => Some(Nfile),
x if x == glib_ffi::G_FILE_ERROR_BADF as i32 => Some(Badf),
x if x == glib_ffi::G_FILE_ERROR_INVAL as i32 => Some(Inval),
x if x == glib_ffi::G_FILE_ERROR_PIPE as i32 => Some(Pipe),
x if x == glib_ffi::G_FILE_ERROR_AGAIN as i32 => Some(Again),
x if x == glib_ffi::G_FILE_ERROR_INTR as i32 => Some(Intr),
x if x == glib_ffi::G_FILE_ERROR_IO as i32 => Some(Io),
x if x == glib_ffi::G_FILE_ERROR_PERM as i32 => Some(Perm),
x if x == glib_ffi::G_FILE_ERROR_NOSYS as i32 => Some(Nosys),
x if x == glib_ffi::G_FILE_ERROR_FAILED as i32 => Some(Failed),
_ => Some(Failed),
}
}
}