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