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