librsvg_rebind/auto/
enums.rs1use crate::ffi;
7use glib::{prelude::*, translate::*};
8
9#[derive(Debug, Eq, PartialEq, Ord, PartialOrd, Hash, Clone, Copy)]
10#[non_exhaustive]
11#[doc(alias = "RsvgError")]
12pub enum Error {
13 #[doc(alias = "RSVG_ERROR_FAILED")]
14 Failed,
15 #[doc(hidden)]
16 __Unknown(i32),
17}
18
19#[doc(hidden)]
20impl IntoGlib for Error {
21 type GlibType = ffi::RsvgError;
22
23 #[inline]
24 fn into_glib(self) -> ffi::RsvgError {
25 match self {
26 Self::Failed => ffi::RSVG_ERROR_FAILED,
27 Self::__Unknown(value) => value,
28 }
29 }
30}
31
32#[doc(hidden)]
33impl FromGlib<ffi::RsvgError> for Error {
34 #[inline]
35 unsafe fn from_glib(value: ffi::RsvgError) -> Self {
36 skip_assert_initialized!();
37
38 match value {
39 ffi::RSVG_ERROR_FAILED => Self::Failed,
40 value => Self::__Unknown(value),
41 }
42 }
43}
44
45impl glib::error::ErrorDomain for Error {
46 #[inline]
47 fn domain() -> glib::Quark {
48 skip_assert_initialized!();
49
50 unsafe { from_glib(ffi::rsvg_error_quark()) }
51 }
52
53 #[inline]
54 fn code(self) -> i32 {
55 self.into_glib()
56 }
57
58 #[inline]
59 #[allow(clippy::match_single_binding)]
60 fn from(code: i32) -> Option<Self> {
61 skip_assert_initialized!();
62 match unsafe { from_glib(code) } {
63 Self::__Unknown(_) => Some(Self::Failed),
64 value => Some(value),
65 }
66 }
67}
68
69impl StaticType for Error {
70 #[inline]
71 #[doc(alias = "rsvg_error_get_type")]
72 fn static_type() -> glib::Type {
73 unsafe { from_glib(ffi::rsvg_error_get_type()) }
74 }
75}
76
77impl glib::HasParamSpec for Error {
78 type ParamSpec = glib::ParamSpecEnum;
79 type SetValue = Self;
80 type BuilderFn = fn(&str, Self) -> glib::ParamSpecEnumBuilder<Self>;
81
82 fn param_spec_builder() -> Self::BuilderFn {
83 Self::ParamSpec::builder_with_default
84 }
85}
86
87impl glib::value::ValueType for Error {
88 type Type = Self;
89}
90
91unsafe impl<'a> glib::value::FromValue<'a> for Error {
92 type Checker = glib::value::GenericValueTypeChecker<Self>;
93
94 #[inline]
95 unsafe fn from_value(value: &'a glib::Value) -> Self {
96 skip_assert_initialized!();
97 unsafe { from_glib(glib::gobject_ffi::g_value_get_enum(value.to_glib_none().0)) }
98 }
99}
100
101impl ToValue for Error {
102 #[inline]
103 fn to_value(&self) -> glib::Value {
104 let mut value = glib::Value::for_value_type::<Self>();
105 unsafe {
106 glib::gobject_ffi::g_value_set_enum(value.to_glib_none_mut().0, self.into_glib());
107 }
108 value
109 }
110
111 #[inline]
112 fn value_type(&self) -> glib::Type {
113 Self::static_type()
114 }
115}
116
117impl From<Error> for glib::Value {
118 #[inline]
119 fn from(v: Error) -> Self {
120 skip_assert_initialized!();
121 ToValue::to_value(&v)
122 }
123}
124
125#[derive(Debug, Eq, PartialEq, Ord, PartialOrd, Hash, Clone, Copy)]
126#[non_exhaustive]
127#[doc(alias = "RsvgUnit")]
128pub enum Unit {
129 #[doc(alias = "RSVG_UNIT_PERCENT")]
130 Percent,
131 #[doc(alias = "RSVG_UNIT_PX")]
132 Px,
133 #[doc(alias = "RSVG_UNIT_EM")]
134 Em,
135 #[doc(alias = "RSVG_UNIT_EX")]
136 Ex,
137 #[doc(alias = "RSVG_UNIT_IN")]
138 In,
139 #[doc(alias = "RSVG_UNIT_CM")]
140 Cm,
141 #[doc(alias = "RSVG_UNIT_MM")]
142 Mm,
143 #[doc(alias = "RSVG_UNIT_PT")]
144 Pt,
145 #[doc(alias = "RSVG_UNIT_PC")]
146 Pc,
147 #[cfg(feature = "v2_58")]
148 #[cfg_attr(docsrs, doc(cfg(feature = "v2_58")))]
149 #[doc(alias = "RSVG_UNIT_CH")]
150 Ch,
151 #[doc(hidden)]
152 __Unknown(i32),
153}
154
155#[doc(hidden)]
156impl IntoGlib for Unit {
157 type GlibType = ffi::RsvgUnit;
158
159 #[inline]
160 fn into_glib(self) -> ffi::RsvgUnit {
161 match self {
162 Self::Percent => ffi::RSVG_UNIT_PERCENT,
163 Self::Px => ffi::RSVG_UNIT_PX,
164 Self::Em => ffi::RSVG_UNIT_EM,
165 Self::Ex => ffi::RSVG_UNIT_EX,
166 Self::In => ffi::RSVG_UNIT_IN,
167 Self::Cm => ffi::RSVG_UNIT_CM,
168 Self::Mm => ffi::RSVG_UNIT_MM,
169 Self::Pt => ffi::RSVG_UNIT_PT,
170 Self::Pc => ffi::RSVG_UNIT_PC,
171 #[cfg(feature = "v2_58")]
172 Self::Ch => ffi::RSVG_UNIT_CH,
173 Self::__Unknown(value) => value,
174 }
175 }
176}
177
178#[doc(hidden)]
179impl FromGlib<ffi::RsvgUnit> for Unit {
180 #[inline]
181 unsafe fn from_glib(value: ffi::RsvgUnit) -> Self {
182 skip_assert_initialized!();
183
184 match value {
185 ffi::RSVG_UNIT_PERCENT => Self::Percent,
186 ffi::RSVG_UNIT_PX => Self::Px,
187 ffi::RSVG_UNIT_EM => Self::Em,
188 ffi::RSVG_UNIT_EX => Self::Ex,
189 ffi::RSVG_UNIT_IN => Self::In,
190 ffi::RSVG_UNIT_CM => Self::Cm,
191 ffi::RSVG_UNIT_MM => Self::Mm,
192 ffi::RSVG_UNIT_PT => Self::Pt,
193 ffi::RSVG_UNIT_PC => Self::Pc,
194 #[cfg(feature = "v2_58")]
195 ffi::RSVG_UNIT_CH => Self::Ch,
196 value => Self::__Unknown(value),
197 }
198 }
199}