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