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
67mod sealed {
68    pub trait Sealed {}
69    impl<T: super::IsA<super::ProxyAddressEnumerator>> Sealed for T {}
70}
71
72/// Trait containing all [`struct@ProxyAddressEnumerator`] methods.
73///
74/// # Implementors
75///
76/// [`ProxyAddressEnumerator`][struct@crate::ProxyAddressEnumerator]
77pub trait ProxyAddressEnumeratorExt:
78    IsA<ProxyAddressEnumerator> + sealed::Sealed + 'static
79{
80    /// The connectable being enumerated.
81    fn connectable(&self) -> Option<SocketConnectable> {
82        ObjectExt::property(self.as_ref(), "connectable")
83    }
84
85    /// The default port to use if #GProxyAddressEnumerator:uri does not
86    /// specify one.
87    #[doc(alias = "default-port")]
88    fn default_port(&self) -> u32 {
89        ObjectExt::property(self.as_ref(), "default-port")
90    }
91
92    /// The proxy resolver to use.
93    #[doc(alias = "proxy-resolver")]
94    fn proxy_resolver(&self) -> Option<ProxyResolver> {
95        ObjectExt::property(self.as_ref(), "proxy-resolver")
96    }
97
98    /// The proxy resolver to use.
99    #[doc(alias = "proxy-resolver")]
100    fn set_proxy_resolver<P: IsA<ProxyResolver>>(&self, proxy_resolver: Option<&P>) {
101        ObjectExt::set_property(self.as_ref(), "proxy-resolver", proxy_resolver)
102    }
103
104    /// The destination URI. Use `none://` for a generic socket.
105    fn uri(&self) -> Option<glib::GString> {
106        ObjectExt::property(self.as_ref(), "uri")
107    }
108
109    #[doc(alias = "proxy-resolver")]
110    fn connect_proxy_resolver_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
111        unsafe extern "C" fn notify_proxy_resolver_trampoline<
112            P: IsA<ProxyAddressEnumerator>,
113            F: Fn(&P) + 'static,
114        >(
115            this: *mut ffi::GProxyAddressEnumerator,
116            _param_spec: glib::ffi::gpointer,
117            f: glib::ffi::gpointer,
118        ) {
119            let f: &F = &*(f as *const F);
120            f(ProxyAddressEnumerator::from_glib_borrow(this).unsafe_cast_ref())
121        }
122        unsafe {
123            let f: Box_<F> = Box_::new(f);
124            connect_raw(
125                self.as_ptr() as *mut _,
126                b"notify::proxy-resolver\0".as_ptr() as *const _,
127                Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
128                    notify_proxy_resolver_trampoline::<Self, F> as *const (),
129                )),
130                Box_::into_raw(f),
131            )
132        }
133    }
134}
135
136impl<O: IsA<ProxyAddressEnumerator>> ProxyAddressEnumeratorExt for O {}