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
// Take a look at the license at the top of the repository in the LICENSE file.

use glib::{bitflags, prelude::*, translate::*, Type};

bitflags::bitflags! {
    #[doc(alias = "GSocketMsgFlags")]
    #[derive(Clone, Copy, Debug, PartialEq, Eq, Hash)]
    pub struct SocketMsgFlags: ffi::GSocketMsgFlags {
        #[doc(alias = "G_SOCKET_MSG_NONE")]
        const NONE = ffi::G_SOCKET_MSG_NONE as _;
        #[doc(alias = "G_SOCKET_MSG_OOB")]
        const OOB = ffi::G_SOCKET_MSG_OOB as _;
        #[doc(alias = "G_SOCKET_MSG_PEEK")]
        const PEEK = ffi::G_SOCKET_MSG_PEEK as _;
        #[doc(alias = "G_SOCKET_MSG_DONTROUTE")]
        const DONTROUTE = ffi::G_SOCKET_MSG_DONTROUTE as _;
    }
}

#[doc(hidden)]
impl IntoGlib for SocketMsgFlags {
    type GlibType = ffi::GSocketMsgFlags;

    #[inline]
    fn into_glib(self) -> ffi::GSocketMsgFlags {
        self.bits()
    }
}

#[doc(hidden)]
impl FromGlib<ffi::GSocketMsgFlags> for SocketMsgFlags {
    #[inline]
    unsafe fn from_glib(value: ffi::GSocketMsgFlags) -> Self {
        Self::from_bits_truncate(value)
    }
}

impl StaticType for SocketMsgFlags {
    #[inline]
    fn static_type() -> Type {
        unsafe { from_glib(ffi::g_socket_msg_flags_get_type()) }
    }
}

impl glib::value::ValueType for SocketMsgFlags {
    type Type = Self;
}

unsafe impl<'a> glib::value::FromValue<'a> for SocketMsgFlags {
    type Checker = glib::value::GenericValueTypeChecker<Self>;

    unsafe fn from_value(value: &'a glib::Value) -> Self {
        from_glib(glib::gobject_ffi::g_value_get_flags(value.to_glib_none().0) as i32)
    }
}

impl ToValue for SocketMsgFlags {
    fn to_value(&self) -> glib::Value {
        let mut value = glib::Value::for_value_type::<Self>();
        unsafe {
            glib::gobject_ffi::g_value_set_flags(
                value.to_glib_none_mut().0,
                self.into_glib() as u32,
            );
        }
        value
    }

    fn value_type(&self) -> glib::Type {
        Self::static_type()
    }
}