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
159mod sealed {
160 pub trait Sealed {}
161 impl<T: super::IsA<super::ProxyAddress>> Sealed for T {}
162}
163
164/// Trait containing all [`struct@ProxyAddress`] methods.
165///
166/// # Implementors
167///
168/// [`ProxyAddress`][struct@crate::ProxyAddress]
169pub trait ProxyAddressExt: IsA<ProxyAddress> + sealed::Sealed + 'static {
170 /// Gets @self's destination hostname; that is, the name of the host
171 /// that will be connected to via the proxy, not the name of the proxy
172 /// itself.
173 ///
174 /// # Returns
175 ///
176 /// the @self's destination hostname
177 #[doc(alias = "g_proxy_address_get_destination_hostname")]
178 #[doc(alias = "get_destination_hostname")]
179 #[doc(alias = "destination-hostname")]
180 fn destination_hostname(&self) -> glib::GString {
181 unsafe {
182 from_glib_none(ffi::g_proxy_address_get_destination_hostname(
183 self.as_ref().to_glib_none().0,
184 ))
185 }
186 }
187
188 /// Gets @self's destination port; that is, the port on the
189 /// destination host that will be connected to via the proxy, not the
190 /// port number of the proxy itself.
191 ///
192 /// # Returns
193 ///
194 /// the @self's destination port
195 #[doc(alias = "g_proxy_address_get_destination_port")]
196 #[doc(alias = "get_destination_port")]
197 #[doc(alias = "destination-port")]
198 fn destination_port(&self) -> u16 {
199 unsafe { ffi::g_proxy_address_get_destination_port(self.as_ref().to_glib_none().0) }
200 }
201
202 /// Gets the protocol that is being spoken to the destination
203 /// server; eg, "http" or "ftp".
204 ///
205 /// # Returns
206 ///
207 /// the @self's destination protocol
208 #[doc(alias = "g_proxy_address_get_destination_protocol")]
209 #[doc(alias = "get_destination_protocol")]
210 #[doc(alias = "destination-protocol")]
211 fn destination_protocol(&self) -> glib::GString {
212 unsafe {
213 from_glib_none(ffi::g_proxy_address_get_destination_protocol(
214 self.as_ref().to_glib_none().0,
215 ))
216 }
217 }
218
219 /// Gets @self's password.
220 ///
221 /// # Returns
222 ///
223 /// the @self's password
224 #[doc(alias = "g_proxy_address_get_password")]
225 #[doc(alias = "get_password")]
226 fn password(&self) -> Option<glib::GString> {
227 unsafe {
228 from_glib_none(ffi::g_proxy_address_get_password(
229 self.as_ref().to_glib_none().0,
230 ))
231 }
232 }
233
234 /// Gets @self's protocol. eg, "socks" or "http"
235 ///
236 /// # Returns
237 ///
238 /// the @self's protocol
239 #[doc(alias = "g_proxy_address_get_protocol")]
240 #[doc(alias = "get_protocol")]
241 fn protocol(&self) -> glib::GString {
242 unsafe {
243 from_glib_none(ffi::g_proxy_address_get_protocol(
244 self.as_ref().to_glib_none().0,
245 ))
246 }
247 }
248
249 /// Gets the proxy URI that @self was constructed from.
250 ///
251 /// # Returns
252 ///
253 /// the @self's URI, or [`None`] if unknown
254 #[doc(alias = "g_proxy_address_get_uri")]
255 #[doc(alias = "get_uri")]
256 fn uri(&self) -> Option<glib::GString> {
257 unsafe { from_glib_none(ffi::g_proxy_address_get_uri(self.as_ref().to_glib_none().0)) }
258 }
259
260 /// Gets @self's username.
261 ///
262 /// # Returns
263 ///
264 /// the @self's username
265 #[doc(alias = "g_proxy_address_get_username")]
266 #[doc(alias = "get_username")]
267 fn username(&self) -> Option<glib::GString> {
268 unsafe {
269 from_glib_none(ffi::g_proxy_address_get_username(
270 self.as_ref().to_glib_none().0,
271 ))
272 }
273 }
274}
275
276impl<O: IsA<ProxyAddress>> ProxyAddressExt for O {}