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 gio_sys;
6use glib::object::Cast;
7use glib::object::IsA;
8use glib::translate::*;
9use glib::GString;
10use std::fmt;
11use InetAddress;
12use InetSocketAddress;
13use SocketAddress;
14use SocketConnectable;
15
16glib_wrapper! {
17    pub struct ProxyAddress(Object<gio_sys::GProxyAddress, gio_sys::GProxyAddressClass, ProxyAddressClass>) @extends InetSocketAddress, SocketAddress, @implements SocketConnectable;
18
19    match fn {
20        get_type => || gio_sys::g_proxy_address_get_type(),
21    }
22}
23
24impl ProxyAddress {
25    pub fn new<P: IsA<InetAddress>>(
26        inetaddr: &P,
27        port: u16,
28        protocol: &str,
29        dest_hostname: &str,
30        dest_port: u16,
31        username: Option<&str>,
32        password: Option<&str>,
33    ) -> ProxyAddress {
34        unsafe {
35            SocketAddress::from_glib_full(gio_sys::g_proxy_address_new(
36                inetaddr.as_ref().to_glib_none().0,
37                port,
38                protocol.to_glib_none().0,
39                dest_hostname.to_glib_none().0,
40                dest_port,
41                username.to_glib_none().0,
42                password.to_glib_none().0,
43            ))
44            .unsafe_cast()
45        }
46    }
47}
48
49unsafe impl Send for ProxyAddress {}
50unsafe impl Sync for ProxyAddress {}
51
52pub const NONE_PROXY_ADDRESS: Option<&ProxyAddress> = None;
53
54pub trait ProxyAddressExt: 'static {
55    fn get_destination_hostname(&self) -> GString;
56
57    fn get_destination_port(&self) -> u16;
58
59    fn get_destination_protocol(&self) -> Option<GString>;
60
61    fn get_password(&self) -> Option<GString>;
62
63    fn get_protocol(&self) -> GString;
64
65    fn get_uri(&self) -> Option<GString>;
66
67    fn get_username(&self) -> Option<GString>;
68}
69
70impl<O: IsA<ProxyAddress>> ProxyAddressExt for O {
71    fn get_destination_hostname(&self) -> GString {
72        unsafe {
73            from_glib_none(gio_sys::g_proxy_address_get_destination_hostname(
74                self.as_ref().to_glib_none().0,
75            ))
76        }
77    }
78
79    fn get_destination_port(&self) -> u16 {
80        unsafe { gio_sys::g_proxy_address_get_destination_port(self.as_ref().to_glib_none().0) }
81    }
82
83    fn get_destination_protocol(&self) -> Option<GString> {
84        unsafe {
85            from_glib_none(gio_sys::g_proxy_address_get_destination_protocol(
86                self.as_ref().to_glib_none().0,
87            ))
88        }
89    }
90
91    fn get_password(&self) -> Option<GString> {
92        unsafe {
93            from_glib_none(gio_sys::g_proxy_address_get_password(
94                self.as_ref().to_glib_none().0,
95            ))
96        }
97    }
98
99    fn get_protocol(&self) -> GString {
100        unsafe {
101            from_glib_none(gio_sys::g_proxy_address_get_protocol(
102                self.as_ref().to_glib_none().0,
103            ))
104        }
105    }
106
107    fn get_uri(&self) -> Option<GString> {
108        unsafe {
109            from_glib_none(gio_sys::g_proxy_address_get_uri(
110                self.as_ref().to_glib_none().0,
111            ))
112        }
113    }
114
115    fn get_username(&self) -> Option<GString> {
116        unsafe {
117            from_glib_none(gio_sys::g_proxy_address_get_username(
118                self.as_ref().to_glib_none().0,
119            ))
120        }
121    }
122}
123
124impl fmt::Display for ProxyAddress {
125    fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
126        write!(f, "ProxyAddress")
127    }
128}