Skip to main content

json_glib/auto/
enums.rs

1// This file was generated by gir (https://github.com/gtk-rs/gir)
2// from gir
3// from gtk-girs (https://github.com/gtk-rs/gir-files)
4// DO NOT EDIT
5
6use crate::{ffi};
7use glib::{prelude::*,translate::*};
8
9/// Indicates the content of a node.
10#[derive(Debug, Eq, PartialEq, Ord, PartialOrd, Hash)]
11#[derive(Clone, Copy)]
12#[non_exhaustive]
13#[doc(alias = "JsonNodeType")]
14pub enum NodeType {
15    /// The node contains a JSON object
16    #[doc(alias = "JSON_NODE_OBJECT")]
17    Object,
18    /// The node contains a JSON array
19    #[doc(alias = "JSON_NODE_ARRAY")]
20    Array,
21    /// The node contains a fundamental type
22    #[doc(alias = "JSON_NODE_VALUE")]
23    Value,
24    /// Special type, for nodes containing null
25    #[doc(alias = "JSON_NODE_NULL")]
26    Null,
27#[doc(hidden)]
28    __Unknown(i32),
29}
30
31#[doc(hidden)]
32impl IntoGlib for NodeType {
33    type GlibType = ffi::JsonNodeType;
34
35    #[inline]
36fn into_glib(self) -> ffi::JsonNodeType {
37match self {
38            Self::Object => ffi::JSON_NODE_OBJECT,
39            Self::Array => ffi::JSON_NODE_ARRAY,
40            Self::Value => ffi::JSON_NODE_VALUE,
41            Self::Null => ffi::JSON_NODE_NULL,
42            Self::__Unknown(value) => value,
43}
44}
45}
46
47#[doc(hidden)]
48impl FromGlib<ffi::JsonNodeType> for NodeType {
49    #[inline]
50unsafe fn from_glib(value: ffi::JsonNodeType) -> Self {
51        skip_assert_initialized!();
52        
53match value {
54            ffi::JSON_NODE_OBJECT => Self::Object,
55            ffi::JSON_NODE_ARRAY => Self::Array,
56            ffi::JSON_NODE_VALUE => Self::Value,
57            ffi::JSON_NODE_NULL => Self::Null,
58            value => Self::__Unknown(value),
59}
60}
61}
62
63impl StaticType for NodeType {
64                #[inline]
65    #[doc(alias = "json_node_type_get_type")]
66   fn static_type() -> glib::Type {
67                    unsafe { from_glib(ffi::json_node_type_get_type()) }
68                }
69            }
70
71impl glib::HasParamSpec for NodeType {
72                type ParamSpec = glib::ParamSpecEnum;
73                type SetValue = Self;
74                type BuilderFn = fn(&str, Self) -> glib::ParamSpecEnumBuilder<Self>;
75    
76                fn param_spec_builder() -> Self::BuilderFn {
77                    Self::ParamSpec::builder_with_default
78                }
79}
80
81impl glib::value::ValueType for NodeType {
82    type Type = Self;
83}
84
85unsafe impl<'a> glib::value::FromValue<'a> for NodeType {
86    type Checker = glib::value::GenericValueTypeChecker<Self>;
87
88    #[inline]
89    unsafe fn from_value(value: &'a glib::Value) -> Self {
90        skip_assert_initialized!();
91        from_glib(glib::gobject_ffi::g_value_get_enum(value.to_glib_none().0))
92    }
93}
94
95impl ToValue for NodeType {
96    #[inline]
97    fn to_value(&self) -> glib::Value {
98        let mut value = glib::Value::for_value_type::<Self>();
99        unsafe {
100            glib::gobject_ffi::g_value_set_enum(value.to_glib_none_mut().0, self.into_glib());
101        }
102        value
103    }
104
105    #[inline]
106    fn value_type(&self) -> glib::Type {
107        Self::static_type()
108    }
109}
110
111impl From<NodeType> for glib::Value {
112    #[inline]
113    fn from(v: NodeType) -> Self {
114        skip_assert_initialized!();
115        ToValue::to_value(&v)
116    }
117}
118
119/// Error codes for `JSON_PARSER_ERROR`.
120///
121/// This enumeration can be extended at later date
122#[derive(Debug, Eq, PartialEq, Ord, PartialOrd, Hash)]
123#[derive(Clone, Copy)]
124#[non_exhaustive]
125#[doc(alias = "JsonParserError")]
126pub enum ParserError {
127    /// parse error
128    #[doc(alias = "JSON_PARSER_ERROR_PARSE")]
129    Parse,
130    /// unexpected trailing comma
131    #[doc(alias = "JSON_PARSER_ERROR_TRAILING_COMMA")]
132    TrailingComma,
133    /// expected comma
134    #[doc(alias = "JSON_PARSER_ERROR_MISSING_COMMA")]
135    MissingComma,
136    /// expected colon
137    #[doc(alias = "JSON_PARSER_ERROR_MISSING_COLON")]
138    MissingColon,
139    /// invalid bareword
140    #[doc(alias = "JSON_PARSER_ERROR_INVALID_BAREWORD")]
141    InvalidBareword,
142    /// Empty member name.
143    #[doc(alias = "JSON_PARSER_ERROR_EMPTY_MEMBER_NAME")]
144    EmptyMemberName,
145    /// Invalid data.
146    #[doc(alias = "JSON_PARSER_ERROR_INVALID_DATA")]
147    InvalidData,
148    /// unknown error
149    #[doc(alias = "JSON_PARSER_ERROR_UNKNOWN")]
150    Unknown,
151    /// Too many levels of nesting.
152    #[cfg(feature = "v1_10")]
153    #[cfg_attr(docsrs, doc(cfg(feature = "v1_10")))]
154    #[doc(alias = "JSON_PARSER_ERROR_NESTING")]
155    Nesting,
156    /// Invalid structure.
157    #[cfg(feature = "v1_10")]
158    #[cfg_attr(docsrs, doc(cfg(feature = "v1_10")))]
159    #[doc(alias = "JSON_PARSER_ERROR_INVALID_STRUCTURE")]
160    InvalidStructure,
161    /// Invalid assignment.
162    #[cfg(feature = "v1_10")]
163    #[cfg_attr(docsrs, doc(cfg(feature = "v1_10")))]
164    #[doc(alias = "JSON_PARSER_ERROR_INVALID_ASSIGNMENT")]
165    InvalidAssignment,
166#[doc(hidden)]
167    __Unknown(i32),
168}
169
170#[doc(hidden)]
171impl IntoGlib for ParserError {
172    type GlibType = ffi::JsonParserError;
173
174    #[inline]
175fn into_glib(self) -> ffi::JsonParserError {
176match self {
177            Self::Parse => ffi::JSON_PARSER_ERROR_PARSE,
178            Self::TrailingComma => ffi::JSON_PARSER_ERROR_TRAILING_COMMA,
179            Self::MissingComma => ffi::JSON_PARSER_ERROR_MISSING_COMMA,
180            Self::MissingColon => ffi::JSON_PARSER_ERROR_MISSING_COLON,
181            Self::InvalidBareword => ffi::JSON_PARSER_ERROR_INVALID_BAREWORD,
182            Self::EmptyMemberName => ffi::JSON_PARSER_ERROR_EMPTY_MEMBER_NAME,
183            Self::InvalidData => ffi::JSON_PARSER_ERROR_INVALID_DATA,
184            Self::Unknown => ffi::JSON_PARSER_ERROR_UNKNOWN,
185            #[cfg(feature = "v1_10")]
186            Self::Nesting => ffi::JSON_PARSER_ERROR_NESTING,
187            #[cfg(feature = "v1_10")]
188            Self::InvalidStructure => ffi::JSON_PARSER_ERROR_INVALID_STRUCTURE,
189            #[cfg(feature = "v1_10")]
190            Self::InvalidAssignment => ffi::JSON_PARSER_ERROR_INVALID_ASSIGNMENT,
191            Self::__Unknown(value) => value,
192}
193}
194}
195
196#[doc(hidden)]
197impl FromGlib<ffi::JsonParserError> for ParserError {
198    #[inline]
199unsafe fn from_glib(value: ffi::JsonParserError) -> Self {
200        skip_assert_initialized!();
201        
202match value {
203            ffi::JSON_PARSER_ERROR_PARSE => Self::Parse,
204            ffi::JSON_PARSER_ERROR_TRAILING_COMMA => Self::TrailingComma,
205            ffi::JSON_PARSER_ERROR_MISSING_COMMA => Self::MissingComma,
206            ffi::JSON_PARSER_ERROR_MISSING_COLON => Self::MissingColon,
207            ffi::JSON_PARSER_ERROR_INVALID_BAREWORD => Self::InvalidBareword,
208            ffi::JSON_PARSER_ERROR_EMPTY_MEMBER_NAME => Self::EmptyMemberName,
209            ffi::JSON_PARSER_ERROR_INVALID_DATA => Self::InvalidData,
210            ffi::JSON_PARSER_ERROR_UNKNOWN => Self::Unknown,
211            #[cfg(feature = "v1_10")]
212            ffi::JSON_PARSER_ERROR_NESTING => Self::Nesting,
213            #[cfg(feature = "v1_10")]
214            ffi::JSON_PARSER_ERROR_INVALID_STRUCTURE => Self::InvalidStructure,
215            #[cfg(feature = "v1_10")]
216            ffi::JSON_PARSER_ERROR_INVALID_ASSIGNMENT => Self::InvalidAssignment,
217            value => Self::__Unknown(value),
218}
219}
220}
221
222impl glib::error::ErrorDomain for ParserError {
223    #[inline]
224    fn domain() -> glib::Quark {
225        skip_assert_initialized!();
226        
227        unsafe { from_glib(ffi::json_parser_error_quark()) }
228    }
229
230    #[inline]
231    fn code(self) -> i32 {
232        self.into_glib()
233    }
234
235    #[inline]
236    #[allow(clippy::match_single_binding)]
237    fn from(code: i32) -> Option<Self> {
238        skip_assert_initialized!();
239        match unsafe { from_glib(code) } {
240            value => Some(value),
241}
242    }
243}
244
245impl StaticType for ParserError {
246                #[inline]
247    #[doc(alias = "json_parser_error_get_type")]
248   fn static_type() -> glib::Type {
249                    unsafe { from_glib(ffi::json_parser_error_get_type()) }
250                }
251            }
252
253impl glib::HasParamSpec for ParserError {
254                type ParamSpec = glib::ParamSpecEnum;
255                type SetValue = Self;
256                type BuilderFn = fn(&str, Self) -> glib::ParamSpecEnumBuilder<Self>;
257    
258                fn param_spec_builder() -> Self::BuilderFn {
259                    Self::ParamSpec::builder_with_default
260                }
261}
262
263impl glib::value::ValueType for ParserError {
264    type Type = Self;
265}
266
267unsafe impl<'a> glib::value::FromValue<'a> for ParserError {
268    type Checker = glib::value::GenericValueTypeChecker<Self>;
269
270    #[inline]
271    unsafe fn from_value(value: &'a glib::Value) -> Self {
272        skip_assert_initialized!();
273        from_glib(glib::gobject_ffi::g_value_get_enum(value.to_glib_none().0))
274    }
275}
276
277impl ToValue for ParserError {
278    #[inline]
279    fn to_value(&self) -> glib::Value {
280        let mut value = glib::Value::for_value_type::<Self>();
281        unsafe {
282            glib::gobject_ffi::g_value_set_enum(value.to_glib_none_mut().0, self.into_glib());
283        }
284        value
285    }
286
287    #[inline]
288    fn value_type(&self) -> glib::Type {
289        Self::static_type()
290    }
291}
292
293impl From<ParserError> for glib::Value {
294    #[inline]
295    fn from(v: ParserError) -> Self {
296        skip_assert_initialized!();
297        ToValue::to_value(&v)
298    }
299}
300
301/// Error codes for `JSON_PATH_ERROR`.
302///
303/// This enumeration can be extended at later date
304#[derive(Debug, Eq, PartialEq, Ord, PartialOrd, Hash)]
305#[derive(Clone, Copy)]
306#[non_exhaustive]
307#[doc(alias = "JsonPathError")]
308pub enum PathError {
309    /// Invalid query
310    #[doc(alias = "JSON_PATH_ERROR_INVALID_QUERY")]
311    Query,
312#[doc(hidden)]
313    __Unknown(i32),
314}
315
316#[doc(hidden)]
317impl IntoGlib for PathError {
318    type GlibType = ffi::JsonPathError;
319
320    #[inline]
321fn into_glib(self) -> ffi::JsonPathError {
322match self {
323            Self::Query => ffi::JSON_PATH_ERROR_INVALID_QUERY,
324            Self::__Unknown(value) => value,
325}
326}
327}
328
329#[doc(hidden)]
330impl FromGlib<ffi::JsonPathError> for PathError {
331    #[inline]
332unsafe fn from_glib(value: ffi::JsonPathError) -> Self {
333        skip_assert_initialized!();
334        
335match value {
336            ffi::JSON_PATH_ERROR_INVALID_QUERY => Self::Query,
337            value => Self::__Unknown(value),
338}
339}
340}
341
342impl glib::error::ErrorDomain for PathError {
343    #[inline]
344    fn domain() -> glib::Quark {
345        skip_assert_initialized!();
346        
347        unsafe { from_glib(ffi::json_path_error_quark()) }
348    }
349
350    #[inline]
351    fn code(self) -> i32 {
352        self.into_glib()
353    }
354
355    #[inline]
356    #[allow(clippy::match_single_binding)]
357    fn from(code: i32) -> Option<Self> {
358        skip_assert_initialized!();
359        match unsafe { from_glib(code) } {
360            value => Some(value),
361}
362    }
363}
364
365impl StaticType for PathError {
366                #[inline]
367    #[doc(alias = "json_path_error_get_type")]
368   fn static_type() -> glib::Type {
369                    unsafe { from_glib(ffi::json_path_error_get_type()) }
370                }
371            }
372
373impl glib::HasParamSpec for PathError {
374                type ParamSpec = glib::ParamSpecEnum;
375                type SetValue = Self;
376                type BuilderFn = fn(&str, Self) -> glib::ParamSpecEnumBuilder<Self>;
377    
378                fn param_spec_builder() -> Self::BuilderFn {
379                    Self::ParamSpec::builder_with_default
380                }
381}
382
383impl glib::value::ValueType for PathError {
384    type Type = Self;
385}
386
387unsafe impl<'a> glib::value::FromValue<'a> for PathError {
388    type Checker = glib::value::GenericValueTypeChecker<Self>;
389
390    #[inline]
391    unsafe fn from_value(value: &'a glib::Value) -> Self {
392        skip_assert_initialized!();
393        from_glib(glib::gobject_ffi::g_value_get_enum(value.to_glib_none().0))
394    }
395}
396
397impl ToValue for PathError {
398    #[inline]
399    fn to_value(&self) -> glib::Value {
400        let mut value = glib::Value::for_value_type::<Self>();
401        unsafe {
402            glib::gobject_ffi::g_value_set_enum(value.to_glib_none_mut().0, self.into_glib());
403        }
404        value
405    }
406
407    #[inline]
408    fn value_type(&self) -> glib::Type {
409        Self::static_type()
410    }
411}
412
413impl From<PathError> for glib::Value {
414    #[inline]
415    fn from(v: PathError) -> Self {
416        skip_assert_initialized!();
417        ToValue::to_value(&v)
418    }
419}
420
421/// Error codes for `JSON_READER_ERROR`.
422///
423/// This enumeration can be extended at later date
424#[derive(Debug, Eq, PartialEq, Ord, PartialOrd, Hash)]
425#[derive(Clone, Copy)]
426#[non_exhaustive]
427#[doc(alias = "JsonReaderError")]
428pub enum ReaderError {
429    /// No array found at the current position
430    #[doc(alias = "JSON_READER_ERROR_NO_ARRAY")]
431    NoArray,
432    /// Index out of bounds
433    #[doc(alias = "JSON_READER_ERROR_INVALID_INDEX")]
434    InvalidIndex,
435    /// No object found at the current position
436    #[doc(alias = "JSON_READER_ERROR_NO_OBJECT")]
437    NoObject,
438    /// Member not found
439    #[doc(alias = "JSON_READER_ERROR_INVALID_MEMBER")]
440    InvalidMember,
441    /// No valid node found at the current position
442    #[doc(alias = "JSON_READER_ERROR_INVALID_NODE")]
443    InvalidNode,
444    /// The node at the current position does not
445    ///   hold a value
446    #[doc(alias = "JSON_READER_ERROR_NO_VALUE")]
447    NoValue,
448    /// The node at the current position does not
449    ///   hold a value of the desired type
450    #[doc(alias = "JSON_READER_ERROR_INVALID_TYPE")]
451    InvalidType,
452#[doc(hidden)]
453    __Unknown(i32),
454}
455
456#[doc(hidden)]
457impl IntoGlib for ReaderError {
458    type GlibType = ffi::JsonReaderError;
459
460    #[inline]
461fn into_glib(self) -> ffi::JsonReaderError {
462match self {
463            Self::NoArray => ffi::JSON_READER_ERROR_NO_ARRAY,
464            Self::InvalidIndex => ffi::JSON_READER_ERROR_INVALID_INDEX,
465            Self::NoObject => ffi::JSON_READER_ERROR_NO_OBJECT,
466            Self::InvalidMember => ffi::JSON_READER_ERROR_INVALID_MEMBER,
467            Self::InvalidNode => ffi::JSON_READER_ERROR_INVALID_NODE,
468            Self::NoValue => ffi::JSON_READER_ERROR_NO_VALUE,
469            Self::InvalidType => ffi::JSON_READER_ERROR_INVALID_TYPE,
470            Self::__Unknown(value) => value,
471}
472}
473}
474
475#[doc(hidden)]
476impl FromGlib<ffi::JsonReaderError> for ReaderError {
477    #[inline]
478unsafe fn from_glib(value: ffi::JsonReaderError) -> Self {
479        skip_assert_initialized!();
480        
481match value {
482            ffi::JSON_READER_ERROR_NO_ARRAY => Self::NoArray,
483            ffi::JSON_READER_ERROR_INVALID_INDEX => Self::InvalidIndex,
484            ffi::JSON_READER_ERROR_NO_OBJECT => Self::NoObject,
485            ffi::JSON_READER_ERROR_INVALID_MEMBER => Self::InvalidMember,
486            ffi::JSON_READER_ERROR_INVALID_NODE => Self::InvalidNode,
487            ffi::JSON_READER_ERROR_NO_VALUE => Self::NoValue,
488            ffi::JSON_READER_ERROR_INVALID_TYPE => Self::InvalidType,
489            value => Self::__Unknown(value),
490}
491}
492}
493
494impl glib::error::ErrorDomain for ReaderError {
495    #[inline]
496    fn domain() -> glib::Quark {
497        skip_assert_initialized!();
498        
499        unsafe { from_glib(ffi::json_reader_error_quark()) }
500    }
501
502    #[inline]
503    fn code(self) -> i32 {
504        self.into_glib()
505    }
506
507    #[inline]
508    #[allow(clippy::match_single_binding)]
509    fn from(code: i32) -> Option<Self> {
510        skip_assert_initialized!();
511        match unsafe { from_glib(code) } {
512            value => Some(value),
513}
514    }
515}
516
517impl StaticType for ReaderError {
518                #[inline]
519    #[doc(alias = "json_reader_error_get_type")]
520   fn static_type() -> glib::Type {
521                    unsafe { from_glib(ffi::json_reader_error_get_type()) }
522                }
523            }
524
525impl glib::HasParamSpec for ReaderError {
526                type ParamSpec = glib::ParamSpecEnum;
527                type SetValue = Self;
528                type BuilderFn = fn(&str, Self) -> glib::ParamSpecEnumBuilder<Self>;
529    
530                fn param_spec_builder() -> Self::BuilderFn {
531                    Self::ParamSpec::builder_with_default
532                }
533}
534
535impl glib::value::ValueType for ReaderError {
536    type Type = Self;
537}
538
539unsafe impl<'a> glib::value::FromValue<'a> for ReaderError {
540    type Checker = glib::value::GenericValueTypeChecker<Self>;
541
542    #[inline]
543    unsafe fn from_value(value: &'a glib::Value) -> Self {
544        skip_assert_initialized!();
545        from_glib(glib::gobject_ffi::g_value_get_enum(value.to_glib_none().0))
546    }
547}
548
549impl ToValue for ReaderError {
550    #[inline]
551    fn to_value(&self) -> glib::Value {
552        let mut value = glib::Value::for_value_type::<Self>();
553        unsafe {
554            glib::gobject_ffi::g_value_set_enum(value.to_glib_none_mut().0, self.into_glib());
555        }
556        value
557    }
558
559    #[inline]
560    fn value_type(&self) -> glib::Type {
561        Self::static_type()
562    }
563}
564
565impl From<ReaderError> for glib::Value {
566    #[inline]
567    fn from(v: ReaderError) -> Self {
568        skip_assert_initialized!();
569        ToValue::to_value(&v)
570    }
571}
572