gio/auto/
proxy_address.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, InetAddress, InetSocketAddress, SocketAddress, SocketConnectable};
6use glib::{prelude::*, translate::*};
7
8glib::wrapper! {
9    /// A [`InetSocketAddress`][crate::InetSocketAddress] representing a connection via a proxy server.
10    ///
11    /// ## Properties
12    ///
13    ///
14    /// #### `destination-hostname`
15    ///  The proxy destination hostname.
16    ///
17    /// Readable | Writeable | Construct Only
18    ///
19    ///
20    /// #### `destination-port`
21    ///  The proxy destination port.
22    ///
23    /// Readable | Writeable | Construct Only
24    ///
25    ///
26    /// #### `destination-protocol`
27    ///  The protocol being spoke to the destination host, or [`None`] if
28    /// the #GProxyAddress doesn't know.
29    ///
30    /// Readable | Writeable | Construct Only
31    ///
32    ///
33    /// #### `password`
34    ///  The proxy password.
35    ///
36    /// Readable | Writeable | Construct Only
37    ///
38    ///
39    /// #### `protocol`
40    ///  The proxy protocol.
41    ///
42    /// Readable | Writeable | Construct Only
43    ///
44    ///
45    /// #### `uri`
46    ///  The URI string that the proxy was constructed from (or [`None`]
47    /// if the creator didn't specify this).
48    ///
49    /// Readable | Writeable | Construct Only
50    ///
51    ///
52    /// #### `username`
53    ///  The proxy username.
54    ///
55    /// Readable | Writeable | Construct Only
56    /// <details><summary><h4>InetSocketAddress</h4></summary>
57    ///
58    ///
59    /// #### `address`
60    ///  The address.
61    ///
62    /// Readable | Writeable | Construct Only
63    ///
64    ///
65    /// #### `flowinfo`
66    ///  The `sin6_flowinfo` field, for IPv6 addresses.
67    ///
68    /// If unset this property is inherited from [`address`][struct@crate::InetSocketAddress#address].
69    ///
70    /// Readable | Writeable | Construct Only
71    ///
72    ///
73    /// #### `port`
74    ///  The port.
75    ///
76    /// Readable | Writeable | Construct Only
77    ///
78    ///
79    /// #### `scope-id`
80    ///  The `sin6_scope_id` field, for IPv6 addresses.
81    ///
82    /// If unset this property is inherited from [`address`][struct@crate::InetSocketAddress#address].
83    ///
84    /// Readable | Writeable | Construct Only
85    /// </details>
86    /// <details><summary><h4>SocketAddress</h4></summary>
87    ///
88    ///
89    /// #### `family`
90    ///  The family of the socket address.
91    ///
92    /// Readable
93    /// </details>
94    ///
95    /// # Implements
96    ///
97    /// [`ProxyAddressExt`][trait@crate::prelude::ProxyAddressExt], [`InetSocketAddressExt`][trait@crate::prelude::InetSocketAddressExt], [`SocketAddressExt`][trait@crate::prelude::SocketAddressExt], [`trait@glib::ObjectExt`], [`SocketConnectableExt`][trait@crate::prelude::SocketConnectableExt]
98    #[doc(alias = "GProxyAddress")]
99    pub struct ProxyAddress(Object<ffi::GProxyAddress, ffi::GProxyAddressClass>) @extends InetSocketAddress, SocketAddress, @implements SocketConnectable;
100
101    match fn {
102        type_ => || ffi::g_proxy_address_get_type(),
103    }
104}
105
106impl ProxyAddress {
107    pub const NONE: Option<&'static ProxyAddress> = None;
108
109    /// Creates a new #GProxyAddress for @inetaddr with @protocol that should
110    /// tunnel through @dest_hostname and @dest_port.
111    ///
112    /// (Note that this method doesn't set the #GProxyAddress:uri or
113    /// #GProxyAddress:destination-protocol fields; use g_object_new()
114    /// directly if you want to set those.)
115    /// ## `inetaddr`
116    /// The proxy server #GInetAddress.
117    /// ## `port`
118    /// The proxy server port.
119    /// ## `protocol`
120    /// The proxy protocol to support, in lower case (e.g. socks, http).
121    /// ## `dest_hostname`
122    /// The destination hostname the proxy should tunnel to.
123    /// ## `dest_port`
124    /// The destination port to tunnel to.
125    /// ## `username`
126    /// The username to authenticate to the proxy server
127    ///     (or [`None`]).
128    /// ## `password`
129    /// The password to authenticate to the proxy server
130    ///     (or [`None`]).
131    ///
132    /// # Returns
133    ///
134    /// a new #GProxyAddress
135    #[doc(alias = "g_proxy_address_new")]
136    pub fn new(
137        inetaddr: &impl IsA<InetAddress>,
138        port: u16,
139        protocol: &str,
140        dest_hostname: &str,
141        dest_port: u16,
142        username: Option<&str>,
143        password: Option<&str>,
144    ) -> ProxyAddress {
145        unsafe {
146            SocketAddress::from_glib_full(ffi::g_proxy_address_new(
147                inetaddr.as_ref().to_glib_none().0,
148                port,
149                protocol.to_glib_none().0,
150                dest_hostname.to_glib_none().0,
151                dest_port,
152                username.to_glib_none().0,
153                password.to_glib_none().0,
154            ))
155            .unsafe_cast()
156        }
157    }
158}
159
160unsafe impl Send for ProxyAddress {}
161unsafe impl Sync for ProxyAddress {}
162
163/// Trait containing all [`struct@ProxyAddress`] methods.
164///
165/// # Implementors
166///
167/// [`ProxyAddress`][struct@crate::ProxyAddress]
168pub trait ProxyAddressExt: IsA<ProxyAddress> + 'static {
169    /// Gets @self's destination hostname; that is, the name of the host
170    /// that will be connected to via the proxy, not the name of the proxy
171    /// itself.
172    ///
173    /// # Returns
174    ///
175    /// the @self's destination hostname
176    #[doc(alias = "g_proxy_address_get_destination_hostname")]
177    #[doc(alias = "get_destination_hostname")]
178    #[doc(alias = "destination-hostname")]
179    fn destination_hostname(&self) -> glib::GString {
180        unsafe {
181            from_glib_none(ffi::g_proxy_address_get_destination_hostname(
182                self.as_ref().to_glib_none().0,
183            ))
184        }
185    }
186
187    /// Gets @self's destination port; that is, the port on the
188    /// destination host that will be connected to via the proxy, not the
189    /// port number of the proxy itself.
190    ///
191    /// # Returns
192    ///
193    /// the @self's destination port
194    #[doc(alias = "g_proxy_address_get_destination_port")]
195    #[doc(alias = "get_destination_port")]
196    #[doc(alias = "destination-port")]
197    fn destination_port(&self) -> u16 {
198        unsafe { ffi::g_proxy_address_get_destination_port(self.as_ref().to_glib_none().0) }
199    }
200
201    /// Gets the protocol that is being spoken to the destination
202    /// server; eg, "http" or "ftp".
203    ///
204    /// # Returns
205    ///
206    /// the @self's destination protocol
207    #[doc(alias = "g_proxy_address_get_destination_protocol")]
208    #[doc(alias = "get_destination_protocol")]
209    #[doc(alias = "destination-protocol")]
210    fn destination_protocol(&self) -> glib::GString {
211        unsafe {
212            from_glib_none(ffi::g_proxy_address_get_destination_protocol(
213                self.as_ref().to_glib_none().0,
214            ))
215        }
216    }
217
218    /// Gets @self's password.
219    ///
220    /// # Returns
221    ///
222    /// the @self's password
223    #[doc(alias = "g_proxy_address_get_password")]
224    #[doc(alias = "get_password")]
225    fn password(&self) -> Option<glib::GString> {
226        unsafe {
227            from_glib_none(ffi::g_proxy_address_get_password(
228                self.as_ref().to_glib_none().0,
229            ))
230        }
231    }
232
233    /// Gets @self's protocol. eg, "socks" or "http"
234    ///
235    /// # Returns
236    ///
237    /// the @self's protocol
238    #[doc(alias = "g_proxy_address_get_protocol")]
239    #[doc(alias = "get_protocol")]
240    fn protocol(&self) -> glib::GString {
241        unsafe {
242            from_glib_none(ffi::g_proxy_address_get_protocol(
243                self.as_ref().to_glib_none().0,
244            ))
245        }
246    }
247
248    /// Gets the proxy URI that @self was constructed from.
249    ///
250    /// # Returns
251    ///
252    /// the @self's URI, or [`None`] if unknown
253    #[doc(alias = "g_proxy_address_get_uri")]
254    #[doc(alias = "get_uri")]
255    fn uri(&self) -> Option<glib::GString> {
256        unsafe { from_glib_none(ffi::g_proxy_address_get_uri(self.as_ref().to_glib_none().0)) }
257    }
258
259    /// Gets @self's username.
260    ///
261    /// # Returns
262    ///
263    /// the @self's username
264    #[doc(alias = "g_proxy_address_get_username")]
265    #[doc(alias = "get_username")]
266    fn username(&self) -> Option<glib::GString> {
267        unsafe {
268            from_glib_none(ffi::g_proxy_address_get_username(
269                self.as_ref().to_glib_none().0,
270            ))
271        }
272    }
273}
274
275impl<O: IsA<ProxyAddress>> ProxyAddressExt for O {}