use crate::{ffi};
use glib::{prelude::*,translate::*};
#[derive(Debug, Eq, PartialEq, Ord, PartialOrd, Hash)]
#[derive(Clone, Copy)]
#[non_exhaustive]
#[doc(alias = "JsonNodeType")]
pub enum NodeType {
#[doc(alias = "JSON_NODE_OBJECT")]
Object,
#[doc(alias = "JSON_NODE_ARRAY")]
Array,
#[doc(alias = "JSON_NODE_VALUE")]
Value,
#[doc(alias = "JSON_NODE_NULL")]
Null,
#[doc(hidden)]
__Unknown(i32),
}
#[doc(hidden)]
impl IntoGlib for NodeType {
type GlibType = ffi::JsonNodeType;
#[inline]
fn into_glib(self) -> ffi::JsonNodeType {
match self {
Self::Object => ffi::JSON_NODE_OBJECT,
Self::Array => ffi::JSON_NODE_ARRAY,
Self::Value => ffi::JSON_NODE_VALUE,
Self::Null => ffi::JSON_NODE_NULL,
Self::__Unknown(value) => value,
}
}
}
#[doc(hidden)]
impl FromGlib<ffi::JsonNodeType> for NodeType {
#[inline]
unsafe fn from_glib(value: ffi::JsonNodeType) -> Self {
skip_assert_initialized!();
match value {
ffi::JSON_NODE_OBJECT => Self::Object,
ffi::JSON_NODE_ARRAY => Self::Array,
ffi::JSON_NODE_VALUE => Self::Value,
ffi::JSON_NODE_NULL => Self::Null,
value => Self::__Unknown(value),
}
}
}
impl StaticType for NodeType {
#[inline]
#[doc(alias = "json_node_type_get_type")]
fn static_type() -> glib::Type {
unsafe { from_glib(ffi::json_node_type_get_type()) }
}
}
impl glib::HasParamSpec for NodeType {
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 NodeType {
type Type = Self;
}
unsafe impl<'a> glib::value::FromValue<'a> for NodeType {
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 NodeType {
#[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<NodeType> for glib::Value {
#[inline]
fn from(v: NodeType) -> Self {
skip_assert_initialized!();
ToValue::to_value(&v)
}
}
#[derive(Debug, Eq, PartialEq, Ord, PartialOrd, Hash)]
#[derive(Clone, Copy)]
#[non_exhaustive]
#[doc(alias = "JsonParserError")]
pub enum ParserError {
#[doc(alias = "JSON_PARSER_ERROR_PARSE")]
Parse,
#[doc(alias = "JSON_PARSER_ERROR_TRAILING_COMMA")]
TrailingComma,
#[doc(alias = "JSON_PARSER_ERROR_MISSING_COMMA")]
MissingComma,
#[doc(alias = "JSON_PARSER_ERROR_MISSING_COLON")]
MissingColon,
#[doc(alias = "JSON_PARSER_ERROR_INVALID_BAREWORD")]
InvalidBareword,
#[doc(alias = "JSON_PARSER_ERROR_EMPTY_MEMBER_NAME")]
EmptyMemberName,
#[doc(alias = "JSON_PARSER_ERROR_INVALID_DATA")]
InvalidData,
#[doc(alias = "JSON_PARSER_ERROR_UNKNOWN")]
Unknown,
#[cfg(feature = "v1_10")]
#[cfg_attr(docsrs, doc(cfg(feature = "v1_10")))]
#[doc(alias = "JSON_PARSER_ERROR_NESTING")]
Nesting,
#[cfg(feature = "v1_10")]
#[cfg_attr(docsrs, doc(cfg(feature = "v1_10")))]
#[doc(alias = "JSON_PARSER_ERROR_INVALID_STRUCTURE")]
InvalidStructure,
#[cfg(feature = "v1_10")]
#[cfg_attr(docsrs, doc(cfg(feature = "v1_10")))]
#[doc(alias = "JSON_PARSER_ERROR_INVALID_ASSIGNMENT")]
InvalidAssignment,
#[doc(hidden)]
__Unknown(i32),
}
#[doc(hidden)]
impl IntoGlib for ParserError {
type GlibType = ffi::JsonParserError;
#[inline]
fn into_glib(self) -> ffi::JsonParserError {
match self {
Self::Parse => ffi::JSON_PARSER_ERROR_PARSE,
Self::TrailingComma => ffi::JSON_PARSER_ERROR_TRAILING_COMMA,
Self::MissingComma => ffi::JSON_PARSER_ERROR_MISSING_COMMA,
Self::MissingColon => ffi::JSON_PARSER_ERROR_MISSING_COLON,
Self::InvalidBareword => ffi::JSON_PARSER_ERROR_INVALID_BAREWORD,
Self::EmptyMemberName => ffi::JSON_PARSER_ERROR_EMPTY_MEMBER_NAME,
Self::InvalidData => ffi::JSON_PARSER_ERROR_INVALID_DATA,
Self::Unknown => ffi::JSON_PARSER_ERROR_UNKNOWN,
#[cfg(feature = "v1_10")]
Self::Nesting => ffi::JSON_PARSER_ERROR_NESTING,
#[cfg(feature = "v1_10")]
Self::InvalidStructure => ffi::JSON_PARSER_ERROR_INVALID_STRUCTURE,
#[cfg(feature = "v1_10")]
Self::InvalidAssignment => ffi::JSON_PARSER_ERROR_INVALID_ASSIGNMENT,
Self::__Unknown(value) => value,
}
}
}
#[doc(hidden)]
impl FromGlib<ffi::JsonParserError> for ParserError {
#[inline]
unsafe fn from_glib(value: ffi::JsonParserError) -> Self {
skip_assert_initialized!();
match value {
ffi::JSON_PARSER_ERROR_PARSE => Self::Parse,
ffi::JSON_PARSER_ERROR_TRAILING_COMMA => Self::TrailingComma,
ffi::JSON_PARSER_ERROR_MISSING_COMMA => Self::MissingComma,
ffi::JSON_PARSER_ERROR_MISSING_COLON => Self::MissingColon,
ffi::JSON_PARSER_ERROR_INVALID_BAREWORD => Self::InvalidBareword,
ffi::JSON_PARSER_ERROR_EMPTY_MEMBER_NAME => Self::EmptyMemberName,
ffi::JSON_PARSER_ERROR_INVALID_DATA => Self::InvalidData,
ffi::JSON_PARSER_ERROR_UNKNOWN => Self::Unknown,
#[cfg(feature = "v1_10")]
ffi::JSON_PARSER_ERROR_NESTING => Self::Nesting,
#[cfg(feature = "v1_10")]
ffi::JSON_PARSER_ERROR_INVALID_STRUCTURE => Self::InvalidStructure,
#[cfg(feature = "v1_10")]
ffi::JSON_PARSER_ERROR_INVALID_ASSIGNMENT => Self::InvalidAssignment,
value => Self::__Unknown(value),
}
}
}
impl glib::error::ErrorDomain for ParserError {
#[inline]
fn domain() -> glib::Quark {
skip_assert_initialized!();
unsafe { from_glib(ffi::json_parser_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) } {
value => Some(value),
}
}
}
impl StaticType for ParserError {
#[inline]
#[doc(alias = "json_parser_error_get_type")]
fn static_type() -> glib::Type {
unsafe { from_glib(ffi::json_parser_error_get_type()) }
}
}
impl glib::HasParamSpec for ParserError {
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 ParserError {
type Type = Self;
}
unsafe impl<'a> glib::value::FromValue<'a> for ParserError {
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 ParserError {
#[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<ParserError> for glib::Value {
#[inline]
fn from(v: ParserError) -> Self {
skip_assert_initialized!();
ToValue::to_value(&v)
}
}
#[derive(Debug, Eq, PartialEq, Ord, PartialOrd, Hash)]
#[derive(Clone, Copy)]
#[non_exhaustive]
#[doc(alias = "JsonPathError")]
pub enum PathError {
#[doc(alias = "JSON_PATH_ERROR_INVALID_QUERY")]
Query,
#[doc(hidden)]
__Unknown(i32),
}
#[doc(hidden)]
impl IntoGlib for PathError {
type GlibType = ffi::JsonPathError;
#[inline]
fn into_glib(self) -> ffi::JsonPathError {
match self {
Self::Query => ffi::JSON_PATH_ERROR_INVALID_QUERY,
Self::__Unknown(value) => value,
}
}
}
#[doc(hidden)]
impl FromGlib<ffi::JsonPathError> for PathError {
#[inline]
unsafe fn from_glib(value: ffi::JsonPathError) -> Self {
skip_assert_initialized!();
match value {
ffi::JSON_PATH_ERROR_INVALID_QUERY => Self::Query,
value => Self::__Unknown(value),
}
}
}
impl glib::error::ErrorDomain for PathError {
#[inline]
fn domain() -> glib::Quark {
skip_assert_initialized!();
unsafe { from_glib(ffi::json_path_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) } {
value => Some(value),
}
}
}
impl StaticType for PathError {
#[inline]
#[doc(alias = "json_path_error_get_type")]
fn static_type() -> glib::Type {
unsafe { from_glib(ffi::json_path_error_get_type()) }
}
}
impl glib::HasParamSpec for PathError {
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 PathError {
type Type = Self;
}
unsafe impl<'a> glib::value::FromValue<'a> for PathError {
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 PathError {
#[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<PathError> for glib::Value {
#[inline]
fn from(v: PathError) -> Self {
skip_assert_initialized!();
ToValue::to_value(&v)
}
}
#[derive(Debug, Eq, PartialEq, Ord, PartialOrd, Hash)]
#[derive(Clone, Copy)]
#[non_exhaustive]
#[doc(alias = "JsonReaderError")]
pub enum ReaderError {
#[doc(alias = "JSON_READER_ERROR_NO_ARRAY")]
NoArray,
#[doc(alias = "JSON_READER_ERROR_INVALID_INDEX")]
InvalidIndex,
#[doc(alias = "JSON_READER_ERROR_NO_OBJECT")]
NoObject,
#[doc(alias = "JSON_READER_ERROR_INVALID_MEMBER")]
InvalidMember,
#[doc(alias = "JSON_READER_ERROR_INVALID_NODE")]
InvalidNode,
#[doc(alias = "JSON_READER_ERROR_NO_VALUE")]
NoValue,
#[doc(alias = "JSON_READER_ERROR_INVALID_TYPE")]
InvalidType,
#[doc(hidden)]
__Unknown(i32),
}
#[doc(hidden)]
impl IntoGlib for ReaderError {
type GlibType = ffi::JsonReaderError;
#[inline]
fn into_glib(self) -> ffi::JsonReaderError {
match self {
Self::NoArray => ffi::JSON_READER_ERROR_NO_ARRAY,
Self::InvalidIndex => ffi::JSON_READER_ERROR_INVALID_INDEX,
Self::NoObject => ffi::JSON_READER_ERROR_NO_OBJECT,
Self::InvalidMember => ffi::JSON_READER_ERROR_INVALID_MEMBER,
Self::InvalidNode => ffi::JSON_READER_ERROR_INVALID_NODE,
Self::NoValue => ffi::JSON_READER_ERROR_NO_VALUE,
Self::InvalidType => ffi::JSON_READER_ERROR_INVALID_TYPE,
Self::__Unknown(value) => value,
}
}
}
#[doc(hidden)]
impl FromGlib<ffi::JsonReaderError> for ReaderError {
#[inline]
unsafe fn from_glib(value: ffi::JsonReaderError) -> Self {
skip_assert_initialized!();
match value {
ffi::JSON_READER_ERROR_NO_ARRAY => Self::NoArray,
ffi::JSON_READER_ERROR_INVALID_INDEX => Self::InvalidIndex,
ffi::JSON_READER_ERROR_NO_OBJECT => Self::NoObject,
ffi::JSON_READER_ERROR_INVALID_MEMBER => Self::InvalidMember,
ffi::JSON_READER_ERROR_INVALID_NODE => Self::InvalidNode,
ffi::JSON_READER_ERROR_NO_VALUE => Self::NoValue,
ffi::JSON_READER_ERROR_INVALID_TYPE => Self::InvalidType,
value => Self::__Unknown(value),
}
}
}
impl glib::error::ErrorDomain for ReaderError {
#[inline]
fn domain() -> glib::Quark {
skip_assert_initialized!();
unsafe { from_glib(ffi::json_reader_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) } {
value => Some(value),
}
}
}
impl StaticType for ReaderError {
#[inline]
#[doc(alias = "json_reader_error_get_type")]
fn static_type() -> glib::Type {
unsafe { from_glib(ffi::json_reader_error_get_type()) }
}
}
impl glib::HasParamSpec for ReaderError {
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 ReaderError {
type Type = Self;
}
unsafe impl<'a> glib::value::FromValue<'a> for ReaderError {
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 ReaderError {
#[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<ReaderError> for glib::Value {
#[inline]
fn from(v: ReaderError) -> Self {
skip_assert_initialized!();
ToValue::to_value(&v)
}
}