gio/auto/proxy_address_enumerator.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::{ffi, ProxyResolver, SocketAddressEnumerator, SocketConnectable};
6use glib::{
7 prelude::*,
8 signal::{connect_raw, SignalHandlerId},
9 translate::*,
10};
11use std::boxed::Box as Box_;
12
13glib::wrapper! {
14 /// `GProxyAddressEnumerator` is a wrapper around
15 /// [`SocketAddressEnumerator`][crate::SocketAddressEnumerator] which takes the [`SocketAddress`][crate::SocketAddress]
16 /// instances returned by the [`SocketAddressEnumerator`][crate::SocketAddressEnumerator]
17 /// and wraps them in [`ProxyAddress`][crate::ProxyAddress] instances, using the given
18 /// [`proxy-resolver`][struct@crate::ProxyAddressEnumerator#proxy-resolver].
19 ///
20 /// This enumerator will be returned (for example, by
21 /// [`SocketConnectableExt::enumerate()`][crate::prelude::SocketConnectableExt::enumerate()]) as appropriate when a proxy is
22 /// configured; there should be no need to manually wrap a
23 /// [`SocketAddressEnumerator`][crate::SocketAddressEnumerator] instance with one.
24 ///
25 /// ## Properties
26 ///
27 ///
28 /// #### `connectable`
29 /// The connectable being enumerated.
30 ///
31 /// Readable | Writeable | Construct Only
32 ///
33 ///
34 /// #### `default-port`
35 /// The default port to use if #GProxyAddressEnumerator:uri does not
36 /// specify one.
37 ///
38 /// Readable | Writeable | Construct Only
39 ///
40 ///
41 /// #### `proxy-resolver`
42 /// The proxy resolver to use.
43 ///
44 /// Readable | Writeable | Construct
45 ///
46 ///
47 /// #### `uri`
48 /// The destination URI. Use `none://` for a generic socket.
49 ///
50 /// Readable | Writeable | Construct Only
51 ///
52 /// # Implements
53 ///
54 /// [`ProxyAddressEnumeratorExt`][trait@crate::prelude::ProxyAddressEnumeratorExt], [`SocketAddressEnumeratorExt`][trait@crate::prelude::SocketAddressEnumeratorExt], [`trait@glib::ObjectExt`]
55 #[doc(alias = "GProxyAddressEnumerator")]
56 pub struct ProxyAddressEnumerator(Object<ffi::GProxyAddressEnumerator, ffi::GProxyAddressEnumeratorClass>) @extends SocketAddressEnumerator;
57
58 match fn {
59 type_ => || ffi::g_proxy_address_enumerator_get_type(),
60 }
61}
62
63impl ProxyAddressEnumerator {
64 pub const NONE: Option<&'static ProxyAddressEnumerator> = None;
65}
66
67/// Trait containing all [`struct@ProxyAddressEnumerator`] methods.
68///
69/// # Implementors
70///
71/// [`ProxyAddressEnumerator`][struct@crate::ProxyAddressEnumerator]
72pub trait ProxyAddressEnumeratorExt: IsA<ProxyAddressEnumerator> + 'static {
73 /// The connectable being enumerated.
74 fn connectable(&self) -> Option<SocketConnectable> {
75 ObjectExt::property(self.as_ref(), "connectable")
76 }
77
78 /// The default port to use if #GProxyAddressEnumerator:uri does not
79 /// specify one.
80 #[doc(alias = "default-port")]
81 fn default_port(&self) -> u32 {
82 ObjectExt::property(self.as_ref(), "default-port")
83 }
84
85 /// The proxy resolver to use.
86 #[doc(alias = "proxy-resolver")]
87 fn proxy_resolver(&self) -> Option<ProxyResolver> {
88 ObjectExt::property(self.as_ref(), "proxy-resolver")
89 }
90
91 /// The proxy resolver to use.
92 #[doc(alias = "proxy-resolver")]
93 fn set_proxy_resolver<P: IsA<ProxyResolver>>(&self, proxy_resolver: Option<&P>) {
94 ObjectExt::set_property(self.as_ref(), "proxy-resolver", proxy_resolver)
95 }
96
97 /// The destination URI. Use `none://` for a generic socket.
98 fn uri(&self) -> Option<glib::GString> {
99 ObjectExt::property(self.as_ref(), "uri")
100 }
101
102 #[doc(alias = "proxy-resolver")]
103 fn connect_proxy_resolver_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
104 unsafe extern "C" fn notify_proxy_resolver_trampoline<
105 P: IsA<ProxyAddressEnumerator>,
106 F: Fn(&P) + 'static,
107 >(
108 this: *mut ffi::GProxyAddressEnumerator,
109 _param_spec: glib::ffi::gpointer,
110 f: glib::ffi::gpointer,
111 ) {
112 let f: &F = &*(f as *const F);
113 f(ProxyAddressEnumerator::from_glib_borrow(this).unsafe_cast_ref())
114 }
115 unsafe {
116 let f: Box_<F> = Box_::new(f);
117 connect_raw(
118 self.as_ptr() as *mut _,
119 c"notify::proxy-resolver".as_ptr() as *const _,
120 Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
121 notify_proxy_resolver_trampoline::<Self, F> as *const (),
122 )),
123 Box_::into_raw(f),
124 )
125 }
126 }
127}
128
129impl<O: IsA<ProxyAddressEnumerator>> ProxyAddressEnumeratorExt for O {}