gio/auto/socket_listener.rs
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
5use crate::{
6 ffi, AsyncResult, Cancellable, Socket, SocketAddress, SocketConnection, SocketListenerEvent,
7 SocketProtocol, SocketType,
8};
9use glib::{
10 object::ObjectType as _,
11 prelude::*,
12 signal::{connect_raw, SignalHandlerId},
13 translate::*,
14};
15use std::{boxed::Box as Box_, pin::Pin};
16
17glib::wrapper! {
18 /// A `GSocketListener` is an object that keeps track of a set
19 /// of server sockets and helps you accept sockets from any of the
20 /// socket, either sync or async.
21 ///
22 /// Add addresses and ports to listen on using
23 /// [`SocketListenerExt::add_address()`][crate::prelude::SocketListenerExt::add_address()] and
24 /// [`SocketListenerExt::add_inet_port()`][crate::prelude::SocketListenerExt::add_inet_port()]. These will be listened on until
25 /// [`SocketListenerExt::close()`][crate::prelude::SocketListenerExt::close()] is called. Dropping your final reference to
26 /// the `GSocketListener` will not cause [`SocketListenerExt::close()`][crate::prelude::SocketListenerExt::close()] to be
27 /// called implicitly, as some references to the `GSocketListener` may be held
28 /// internally.
29 ///
30 /// If you want to implement a network server, also look at
31 /// [`SocketService`][crate::SocketService] and [`ThreadedSocketService`][crate::ThreadedSocketService] which are
32 /// subclasses of `GSocketListener` that make this even easier.
33 ///
34 /// ## Properties
35 ///
36 ///
37 /// #### `listen-backlog`
38 /// The number of outstanding connections in the listen queue.
39 ///
40 /// Readable | Writeable | Construct
41 ///
42 /// ## Signals
43 ///
44 ///
45 /// #### `event`
46 /// Emitted when @listener's activity on @socket changes state.
47 /// Note that when @listener is used to listen on both IPv4 and
48 /// IPv6, a separate set of signals will be emitted for each, and
49 /// the order they happen in is undefined.
50 ///
51 ///
52 ///
53 /// # Implements
54 ///
55 /// [`SocketListenerExt`][trait@crate::prelude::SocketListenerExt], [`trait@glib::ObjectExt`], [`SocketListenerExtManual`][trait@crate::prelude::SocketListenerExtManual]
56 #[doc(alias = "GSocketListener")]
57 pub struct SocketListener(Object<ffi::GSocketListener, ffi::GSocketListenerClass>);
58
59 match fn {
60 type_ => || ffi::g_socket_listener_get_type(),
61 }
62}
63
64impl SocketListener {
65 pub const NONE: Option<&'static SocketListener> = None;
66
67 /// Creates a new #GSocketListener with no sockets to listen for.
68 /// New listeners can be added with e.g. g_socket_listener_add_address()
69 /// or g_socket_listener_add_inet_port().
70 ///
71 /// # Returns
72 ///
73 /// a new #GSocketListener.
74 #[doc(alias = "g_socket_listener_new")]
75 pub fn new() -> SocketListener {
76 unsafe { from_glib_full(ffi::g_socket_listener_new()) }
77 }
78}
79
80impl Default for SocketListener {
81 fn default() -> Self {
82 Self::new()
83 }
84}
85
86/// Trait containing all [`struct@SocketListener`] methods.
87///
88/// # Implementors
89///
90/// [`SocketListener`][struct@crate::SocketListener], [`SocketService`][struct@crate::SocketService]
91pub trait SocketListenerExt: IsA<SocketListener> + 'static {
92 /// Blocks waiting for a client to connect to any of the sockets added
93 /// to the listener. Returns a #GSocketConnection for the socket that was
94 /// accepted.
95 ///
96 /// If @source_object is not [`None`] it will be filled out with the source
97 /// object specified when the corresponding socket or address was added
98 /// to the listener.
99 ///
100 /// If @cancellable is not [`None`], then the operation can be cancelled by
101 /// triggering the cancellable object from another thread. If the operation
102 /// was cancelled, the error [`IOErrorEnum::Cancelled`][crate::IOErrorEnum::Cancelled] will be returned.
103 /// ## `cancellable`
104 /// optional #GCancellable object, [`None`] to ignore.
105 ///
106 /// # Returns
107 ///
108 /// a #GSocketConnection on success, [`None`] on error.
109 ///
110 /// ## `source_object`
111 /// location where #GObject pointer will be stored, or [`None`]
112 #[doc(alias = "g_socket_listener_accept")]
113 fn accept(
114 &self,
115 cancellable: Option<&impl IsA<Cancellable>>,
116 ) -> Result<(SocketConnection, Option<glib::Object>), glib::Error> {
117 unsafe {
118 let mut source_object = std::ptr::null_mut();
119 let mut error = std::ptr::null_mut();
120 let ret = ffi::g_socket_listener_accept(
121 self.as_ref().to_glib_none().0,
122 &mut source_object,
123 cancellable.map(|p| p.as_ref()).to_glib_none().0,
124 &mut error,
125 );
126 if error.is_null() {
127 Ok((from_glib_full(ret), from_glib_none(source_object)))
128 } else {
129 Err(from_glib_full(error))
130 }
131 }
132 }
133
134 /// This is the asynchronous version of g_socket_listener_accept().
135 ///
136 /// When the operation is finished @callback will be
137 /// called. You can then call g_socket_listener_accept_finish()
138 /// to get the result of the operation.
139 /// ## `cancellable`
140 /// a #GCancellable, or [`None`]
141 /// ## `callback`
142 /// a #GAsyncReadyCallback
143 #[doc(alias = "g_socket_listener_accept_async")]
144 fn accept_async<
145 P: FnOnce(Result<(SocketConnection, Option<glib::Object>), glib::Error>) + 'static,
146 >(
147 &self,
148 cancellable: Option<&impl IsA<Cancellable>>,
149 callback: P,
150 ) {
151 let main_context = glib::MainContext::ref_thread_default();
152 let is_main_context_owner = main_context.is_owner();
153 let has_acquired_main_context = (!is_main_context_owner)
154 .then(|| main_context.acquire().ok())
155 .flatten();
156 assert!(
157 is_main_context_owner || has_acquired_main_context.is_some(),
158 "Async operations only allowed if the thread is owning the MainContext"
159 );
160
161 let user_data: Box_<glib::thread_guard::ThreadGuard<P>> =
162 Box_::new(glib::thread_guard::ThreadGuard::new(callback));
163 unsafe extern "C" fn accept_async_trampoline<
164 P: FnOnce(Result<(SocketConnection, Option<glib::Object>), glib::Error>) + 'static,
165 >(
166 _source_object: *mut glib::gobject_ffi::GObject,
167 res: *mut crate::ffi::GAsyncResult,
168 user_data: glib::ffi::gpointer,
169 ) {
170 let mut error = std::ptr::null_mut();
171 let mut source_object = std::ptr::null_mut();
172 let ret = ffi::g_socket_listener_accept_finish(
173 _source_object as *mut _,
174 res,
175 &mut source_object,
176 &mut error,
177 );
178 let result = if error.is_null() {
179 Ok((from_glib_full(ret), from_glib_none(source_object)))
180 } else {
181 Err(from_glib_full(error))
182 };
183 let callback: Box_<glib::thread_guard::ThreadGuard<P>> =
184 Box_::from_raw(user_data as *mut _);
185 let callback: P = callback.into_inner();
186 callback(result);
187 }
188 let callback = accept_async_trampoline::<P>;
189 unsafe {
190 ffi::g_socket_listener_accept_async(
191 self.as_ref().to_glib_none().0,
192 cancellable.map(|p| p.as_ref()).to_glib_none().0,
193 Some(callback),
194 Box_::into_raw(user_data) as *mut _,
195 );
196 }
197 }
198
199 fn accept_future(
200 &self,
201 ) -> Pin<
202 Box_<
203 dyn std::future::Future<
204 Output = Result<(SocketConnection, Option<glib::Object>), glib::Error>,
205 > + 'static,
206 >,
207 > {
208 Box_::pin(crate::GioFuture::new(
209 self,
210 move |obj, cancellable, send| {
211 obj.accept_async(Some(cancellable), move |res| {
212 send.resolve(res);
213 });
214 },
215 ))
216 }
217
218 /// Blocks waiting for a client to connect to any of the sockets added
219 /// to the listener. Returns the #GSocket that was accepted.
220 ///
221 /// If you want to accept the high-level #GSocketConnection, not a #GSocket,
222 /// which is often the case, then you should use g_socket_listener_accept()
223 /// instead.
224 ///
225 /// If @source_object is not [`None`] it will be filled out with the source
226 /// object specified when the corresponding socket or address was added
227 /// to the listener.
228 ///
229 /// If @cancellable is not [`None`], then the operation can be cancelled by
230 /// triggering the cancellable object from another thread. If the operation
231 /// was cancelled, the error [`IOErrorEnum::Cancelled`][crate::IOErrorEnum::Cancelled] will be returned.
232 /// ## `cancellable`
233 /// optional #GCancellable object, [`None`] to ignore.
234 ///
235 /// # Returns
236 ///
237 /// a #GSocket on success, [`None`] on error.
238 ///
239 /// ## `source_object`
240 /// location where #GObject pointer will be stored, or [`None`].
241 #[doc(alias = "g_socket_listener_accept_socket")]
242 fn accept_socket(
243 &self,
244 cancellable: Option<&impl IsA<Cancellable>>,
245 ) -> Result<(Socket, Option<glib::Object>), glib::Error> {
246 unsafe {
247 let mut source_object = std::ptr::null_mut();
248 let mut error = std::ptr::null_mut();
249 let ret = ffi::g_socket_listener_accept_socket(
250 self.as_ref().to_glib_none().0,
251 &mut source_object,
252 cancellable.map(|p| p.as_ref()).to_glib_none().0,
253 &mut error,
254 );
255 if error.is_null() {
256 Ok((from_glib_full(ret), from_glib_none(source_object)))
257 } else {
258 Err(from_glib_full(error))
259 }
260 }
261 }
262
263 /// This is the asynchronous version of g_socket_listener_accept_socket().
264 ///
265 /// When the operation is finished @callback will be
266 /// called. You can then call g_socket_listener_accept_socket_finish()
267 /// to get the result of the operation.
268 /// ## `cancellable`
269 /// a #GCancellable, or [`None`]
270 /// ## `callback`
271 /// a #GAsyncReadyCallback
272 #[doc(alias = "g_socket_listener_accept_socket_async")]
273 fn accept_socket_async<
274 P: FnOnce(Result<(Socket, Option<glib::Object>), glib::Error>) + 'static,
275 >(
276 &self,
277 cancellable: Option<&impl IsA<Cancellable>>,
278 callback: P,
279 ) {
280 let main_context = glib::MainContext::ref_thread_default();
281 let is_main_context_owner = main_context.is_owner();
282 let has_acquired_main_context = (!is_main_context_owner)
283 .then(|| main_context.acquire().ok())
284 .flatten();
285 assert!(
286 is_main_context_owner || has_acquired_main_context.is_some(),
287 "Async operations only allowed if the thread is owning the MainContext"
288 );
289
290 let user_data: Box_<glib::thread_guard::ThreadGuard<P>> =
291 Box_::new(glib::thread_guard::ThreadGuard::new(callback));
292 unsafe extern "C" fn accept_socket_async_trampoline<
293 P: FnOnce(Result<(Socket, Option<glib::Object>), glib::Error>) + 'static,
294 >(
295 _source_object: *mut glib::gobject_ffi::GObject,
296 res: *mut crate::ffi::GAsyncResult,
297 user_data: glib::ffi::gpointer,
298 ) {
299 let mut error = std::ptr::null_mut();
300 let mut source_object = std::ptr::null_mut();
301 let ret = ffi::g_socket_listener_accept_socket_finish(
302 _source_object as *mut _,
303 res,
304 &mut source_object,
305 &mut error,
306 );
307 let result = if error.is_null() {
308 Ok((from_glib_full(ret), from_glib_none(source_object)))
309 } else {
310 Err(from_glib_full(error))
311 };
312 let callback: Box_<glib::thread_guard::ThreadGuard<P>> =
313 Box_::from_raw(user_data as *mut _);
314 let callback: P = callback.into_inner();
315 callback(result);
316 }
317 let callback = accept_socket_async_trampoline::<P>;
318 unsafe {
319 ffi::g_socket_listener_accept_socket_async(
320 self.as_ref().to_glib_none().0,
321 cancellable.map(|p| p.as_ref()).to_glib_none().0,
322 Some(callback),
323 Box_::into_raw(user_data) as *mut _,
324 );
325 }
326 }
327
328 fn accept_socket_future(
329 &self,
330 ) -> Pin<
331 Box_<
332 dyn std::future::Future<Output = Result<(Socket, Option<glib::Object>), glib::Error>>
333 + 'static,
334 >,
335 > {
336 Box_::pin(crate::GioFuture::new(
337 self,
338 move |obj, cancellable, send| {
339 obj.accept_socket_async(Some(cancellable), move |res| {
340 send.resolve(res);
341 });
342 },
343 ))
344 }
345
346 /// Creates a socket of type @type_ and protocol @protocol, binds
347 /// it to @address and adds it to the set of sockets we're accepting
348 /// sockets from.
349 ///
350 /// Note that adding an IPv6 address, depending on the platform,
351 /// may or may not result in a listener that also accepts IPv4
352 /// connections. For more deterministic behavior, see
353 /// g_socket_listener_add_inet_port().
354 ///
355 /// @source_object will be passed out in the various calls
356 /// to accept to identify this particular source, which is
357 /// useful if you're listening on multiple addresses and do
358 /// different things depending on what address is connected to.
359 ///
360 /// If successful and @effective_address is non-[`None`] then it will
361 /// be set to the address that the binding actually occurred at. This
362 /// is helpful for determining the port number that was used for when
363 /// requesting a binding to port 0 (ie: "any port"). This address, if
364 /// requested, belongs to the caller and must be freed.
365 ///
366 /// Call g_socket_listener_close() to stop listening on @address; this will not
367 /// be done automatically when you drop your final reference to @self, as
368 /// references may be held internally.
369 /// ## `address`
370 /// a #GSocketAddress
371 /// ## `type_`
372 /// a #GSocketType
373 /// ## `protocol`
374 /// a #GSocketProtocol
375 /// ## `source_object`
376 /// Optional #GObject identifying this source
377 ///
378 /// # Returns
379 ///
380 /// [`true`] on success, [`false`] on error.
381 ///
382 /// ## `effective_address`
383 /// location to store the address that was bound to, or [`None`].
384 #[doc(alias = "g_socket_listener_add_address")]
385 fn add_address(
386 &self,
387 address: &impl IsA<SocketAddress>,
388 type_: SocketType,
389 protocol: SocketProtocol,
390 source_object: Option<&impl IsA<glib::Object>>,
391 ) -> Result<SocketAddress, glib::Error> {
392 unsafe {
393 let mut effective_address = std::ptr::null_mut();
394 let mut error = std::ptr::null_mut();
395 let is_ok = ffi::g_socket_listener_add_address(
396 self.as_ref().to_glib_none().0,
397 address.as_ref().to_glib_none().0,
398 type_.into_glib(),
399 protocol.into_glib(),
400 source_object.map(|p| p.as_ref()).to_glib_none().0,
401 &mut effective_address,
402 &mut error,
403 );
404 debug_assert_eq!(is_ok == glib::ffi::GFALSE, !error.is_null());
405 if error.is_null() {
406 Ok(from_glib_full(effective_address))
407 } else {
408 Err(from_glib_full(error))
409 }
410 }
411 }
412
413 /// Listens for TCP connections on any available port number for both
414 /// IPv6 and IPv4 (if each is available).
415 ///
416 /// This is useful if you need to have a socket for incoming connections
417 /// but don't care about the specific port number.
418 ///
419 /// If possible, the [`SocketListener`][crate::SocketListener] will listen on both IPv4 and
420 /// IPv6 (listening on the same port on both). If listening on one of the socket
421 /// families fails, the [`SocketListener`][crate::SocketListener] will only listen on the other.
422 /// If listening on both fails, an error will be returned.
423 ///
424 /// If you need to distinguish whether listening on IPv4 or IPv6 or both was
425 /// successful, connect to [`event`][struct@crate::SocketListener#event].
426 ///
427 /// @source_object will be passed out in the various calls
428 /// to accept to identify this particular source, which is
429 /// useful if you're listening on multiple addresses and do
430 /// different things depending on what address is connected to.
431 /// ## `source_object`
432 /// Optional #GObject identifying this source
433 ///
434 /// # Returns
435 ///
436 /// the port number, or 0 in case of failure.
437 #[doc(alias = "g_socket_listener_add_any_inet_port")]
438 fn add_any_inet_port(
439 &self,
440 source_object: Option<&impl IsA<glib::Object>>,
441 ) -> Result<u16, glib::Error> {
442 unsafe {
443 let mut error = std::ptr::null_mut();
444 let ret = ffi::g_socket_listener_add_any_inet_port(
445 self.as_ref().to_glib_none().0,
446 source_object.map(|p| p.as_ref()).to_glib_none().0,
447 &mut error,
448 );
449 if error.is_null() {
450 Ok(ret)
451 } else {
452 Err(from_glib_full(error))
453 }
454 }
455 }
456
457 /// Helper function for g_socket_listener_add_address() that
458 /// creates a TCP/IP socket listening on IPv4 and IPv6 (if
459 /// supported) on the specified port on all interfaces.
460 ///
461 /// If possible, the [`SocketListener`][crate::SocketListener] will listen on both IPv4 and
462 /// IPv6 (listening on the same port on both). If listening on one of the socket
463 /// families fails, the [`SocketListener`][crate::SocketListener] will only listen on the other.
464 /// If listening on both fails, an error will be returned.
465 ///
466 /// If you need to distinguish whether listening on IPv4 or IPv6 or both was
467 /// successful, connect to [`event`][struct@crate::SocketListener#event].
468 ///
469 /// @source_object will be passed out in the various calls
470 /// to accept to identify this particular source, which is
471 /// useful if you're listening on multiple addresses and do
472 /// different things depending on what address is connected to.
473 ///
474 /// Call g_socket_listener_close() to stop listening on @port; this will not
475 /// be done automatically when you drop your final reference to @self, as
476 /// references may be held internally.
477 /// ## `port`
478 /// an IP port number (non-zero)
479 /// ## `source_object`
480 /// Optional #GObject identifying this source
481 ///
482 /// # Returns
483 ///
484 /// [`true`] on success, [`false`] on error.
485 #[doc(alias = "g_socket_listener_add_inet_port")]
486 fn add_inet_port(
487 &self,
488 port: u16,
489 source_object: Option<&impl IsA<glib::Object>>,
490 ) -> Result<(), glib::Error> {
491 unsafe {
492 let mut error = std::ptr::null_mut();
493 let is_ok = ffi::g_socket_listener_add_inet_port(
494 self.as_ref().to_glib_none().0,
495 port,
496 source_object.map(|p| p.as_ref()).to_glib_none().0,
497 &mut error,
498 );
499 debug_assert_eq!(is_ok == glib::ffi::GFALSE, !error.is_null());
500 if error.is_null() {
501 Ok(())
502 } else {
503 Err(from_glib_full(error))
504 }
505 }
506 }
507
508 /// Adds @socket to the set of sockets that we try to accept
509 /// new clients from. The socket must be bound to a local
510 /// address and listened to.
511 ///
512 /// For parallel calls to [`SocketListener`][crate::SocketListener] methods to work, the socket
513 /// must be in non-blocking mode. (See [`blocking`][struct@crate::Socket#blocking].)
514 ///
515 /// @source_object will be passed out in the various calls
516 /// to accept to identify this particular source, which is
517 /// useful if you're listening on multiple addresses and do
518 /// different things depending on what address is connected to.
519 ///
520 /// The @socket will not be automatically closed when the @self is finalized
521 /// unless the listener held the final reference to the socket. Before GLib 2.42,
522 /// the @socket was automatically closed on finalization of the @self, even
523 /// if references to it were held elsewhere.
524 /// ## `socket`
525 /// a listening #GSocket
526 /// ## `source_object`
527 /// Optional #GObject identifying this source
528 ///
529 /// # Returns
530 ///
531 /// [`true`] on success, [`false`] on error.
532 #[doc(alias = "g_socket_listener_add_socket")]
533 fn add_socket(
534 &self,
535 socket: &impl IsA<Socket>,
536 source_object: Option<&impl IsA<glib::Object>>,
537 ) -> Result<(), glib::Error> {
538 unsafe {
539 let mut error = std::ptr::null_mut();
540 let is_ok = ffi::g_socket_listener_add_socket(
541 self.as_ref().to_glib_none().0,
542 socket.as_ref().to_glib_none().0,
543 source_object.map(|p| p.as_ref()).to_glib_none().0,
544 &mut error,
545 );
546 debug_assert_eq!(is_ok == glib::ffi::GFALSE, !error.is_null());
547 if error.is_null() {
548 Ok(())
549 } else {
550 Err(from_glib_full(error))
551 }
552 }
553 }
554
555 /// Closes all the sockets in the listener.
556 #[doc(alias = "g_socket_listener_close")]
557 fn close(&self) {
558 unsafe {
559 ffi::g_socket_listener_close(self.as_ref().to_glib_none().0);
560 }
561 }
562
563 /// Sets the listen backlog on the sockets in the listener. This must be called
564 /// before adding any sockets, addresses or ports to the #GSocketListener (for
565 /// example, by calling g_socket_listener_add_inet_port()) to be effective.
566 ///
567 /// See g_socket_set_listen_backlog() for details
568 /// ## `listen_backlog`
569 /// an integer
570 #[doc(alias = "g_socket_listener_set_backlog")]
571 fn set_backlog(&self, listen_backlog: i32) {
572 unsafe {
573 ffi::g_socket_listener_set_backlog(self.as_ref().to_glib_none().0, listen_backlog);
574 }
575 }
576
577 /// The number of outstanding connections in the listen queue.
578 #[doc(alias = "listen-backlog")]
579 fn listen_backlog(&self) -> i32 {
580 ObjectExt::property(self.as_ref(), "listen-backlog")
581 }
582
583 /// The number of outstanding connections in the listen queue.
584 #[doc(alias = "listen-backlog")]
585 fn set_listen_backlog(&self, listen_backlog: i32) {
586 ObjectExt::set_property(self.as_ref(), "listen-backlog", listen_backlog)
587 }
588
589 /// Emitted when @listener's activity on @socket changes state.
590 /// Note that when @listener is used to listen on both IPv4 and
591 /// IPv6, a separate set of signals will be emitted for each, and
592 /// the order they happen in is undefined.
593 /// ## `event`
594 /// the event that is occurring
595 /// ## `socket`
596 /// the #GSocket the event is occurring on
597 #[doc(alias = "event")]
598 fn connect_event<F: Fn(&Self, SocketListenerEvent, &Socket) + 'static>(
599 &self,
600 f: F,
601 ) -> SignalHandlerId {
602 unsafe extern "C" fn event_trampoline<
603 P: IsA<SocketListener>,
604 F: Fn(&P, SocketListenerEvent, &Socket) + 'static,
605 >(
606 this: *mut ffi::GSocketListener,
607 event: ffi::GSocketListenerEvent,
608 socket: *mut ffi::GSocket,
609 f: glib::ffi::gpointer,
610 ) {
611 let f: &F = &*(f as *const F);
612 f(
613 SocketListener::from_glib_borrow(this).unsafe_cast_ref(),
614 from_glib(event),
615 &from_glib_borrow(socket),
616 )
617 }
618 unsafe {
619 let f: Box_<F> = Box_::new(f);
620 connect_raw(
621 self.as_ptr() as *mut _,
622 c"event".as_ptr() as *const _,
623 Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
624 event_trampoline::<Self, F> as *const (),
625 )),
626 Box_::into_raw(f),
627 )
628 }
629 }
630
631 #[doc(alias = "listen-backlog")]
632 fn connect_listen_backlog_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
633 unsafe extern "C" fn notify_listen_backlog_trampoline<
634 P: IsA<SocketListener>,
635 F: Fn(&P) + 'static,
636 >(
637 this: *mut ffi::GSocketListener,
638 _param_spec: glib::ffi::gpointer,
639 f: glib::ffi::gpointer,
640 ) {
641 let f: &F = &*(f as *const F);
642 f(SocketListener::from_glib_borrow(this).unsafe_cast_ref())
643 }
644 unsafe {
645 let f: Box_<F> = Box_::new(f);
646 connect_raw(
647 self.as_ptr() as *mut _,
648 c"notify::listen-backlog".as_ptr() as *const _,
649 Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
650 notify_listen_backlog_trampoline::<Self, F> as *const (),
651 )),
652 Box_::into_raw(f),
653 )
654 }
655 }
656}
657
658impl<O: IsA<SocketListener>> SocketListenerExt for O {}