1 // This file was generated by gir (https://github.com/gtk-rs/gir)
2 // from gir-files (https://github.com/gtk-rs/gir-files)
3 // DO NOT EDIT
4 
5 use crate::SocketConnection;
6 use crate::SocketListener;
7 use crate::SocketService;
8 use glib::object::Cast;
9 use glib::object::IsA;
10 use glib::signal::connect_raw;
11 use glib::signal::SignalHandlerId;
12 use glib::translate::*;
13 use glib::StaticType;
14 use std::boxed::Box as Box_;
15 use std::fmt;
16 use std::mem::transmute;
17 
18 glib::wrapper! {
19     #[doc(alias = "GThreadedSocketService")]
20     pub struct ThreadedSocketService(Object<ffi::GThreadedSocketService, ffi::GThreadedSocketServiceClass>) @extends SocketService, SocketListener;
21 
22     match fn {
23         type_ => || ffi::g_threaded_socket_service_get_type(),
24     }
25 }
26 
27 pub const NONE_THREADED_SOCKET_SERVICE: Option<&ThreadedSocketService> = None;
28 
29 pub trait ThreadedSocketServiceExt: 'static {
30     #[doc(alias = "max-threads")]
max_threads(&self) -> i3231     fn max_threads(&self) -> i32;
32 
33     #[doc(alias = "run")]
connect_run<F: Fn(&Self, &SocketConnection, Option<&glib::Object>) -> bool + 'static>( &self, f: F, ) -> SignalHandlerId34     fn connect_run<F: Fn(&Self, &SocketConnection, Option<&glib::Object>) -> bool + 'static>(
35         &self,
36         f: F,
37     ) -> SignalHandlerId;
38 }
39 
40 impl<O: IsA<ThreadedSocketService>> ThreadedSocketServiceExt for O {
max_threads(&self) -> i3241     fn max_threads(&self) -> i32 {
42         unsafe {
43             let mut value = glib::Value::from_type(<i32 as StaticType>::static_type());
44             glib::gobject_ffi::g_object_get_property(
45                 self.to_glib_none().0 as *mut glib::gobject_ffi::GObject,
46                 b"max-threads\0".as_ptr() as *const _,
47                 value.to_glib_none_mut().0,
48             );
49             value
50                 .get()
51                 .expect("Return Value for property `max-threads` getter")
52         }
53     }
54 
connect_run<F: Fn(&Self, &SocketConnection, Option<&glib::Object>) -> bool + 'static>( &self, f: F, ) -> SignalHandlerId55     fn connect_run<F: Fn(&Self, &SocketConnection, Option<&glib::Object>) -> bool + 'static>(
56         &self,
57         f: F,
58     ) -> SignalHandlerId {
59         unsafe extern "C" fn run_trampoline<
60             P: IsA<ThreadedSocketService>,
61             F: Fn(&P, &SocketConnection, Option<&glib::Object>) -> bool + 'static,
62         >(
63             this: *mut ffi::GThreadedSocketService,
64             connection: *mut ffi::GSocketConnection,
65             source_object: *mut glib::gobject_ffi::GObject,
66             f: glib::ffi::gpointer,
67         ) -> glib::ffi::gboolean {
68             let f: &F = &*(f as *const F);
69             f(
70                 ThreadedSocketService::from_glib_borrow(this).unsafe_cast_ref(),
71                 &from_glib_borrow(connection),
72                 Option::<glib::Object>::from_glib_borrow(source_object)
73                     .as_ref()
74                     .as_ref(),
75             )
76             .into_glib()
77         }
78         unsafe {
79             let f: Box_<F> = Box_::new(f);
80             connect_raw(
81                 self.as_ptr() as *mut _,
82                 b"run\0".as_ptr() as *const _,
83                 Some(transmute::<_, unsafe extern "C" fn()>(
84                     run_trampoline::<Self, F> as *const (),
85                 )),
86                 Box_::into_raw(f),
87             )
88         }
89     }
90 }
91 
92 impl fmt::Display for ThreadedSocketService {
fmt(&self, f: &mut fmt::Formatter) -> fmt::Result93     fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
94         f.write_str("ThreadedSocketService")
95     }
96 }
97