Skip to main content

spice_client_glib/auto/
uri.rs

1// This file was generated by gir (https://github.com/gtk-rs/gir)
2// from
3// from gir-files (https://github.com/gtk-rs/gir-files.git)
4// DO NOT EDIT
5
6use crate::ffi;
7use glib::{
8    prelude::*,
9    signal::{connect_raw, SignalHandlerId},
10    translate::*,
11};
12use std::boxed::Box as Box_;
13
14glib::wrapper! {
15    #[doc(alias = "SpiceURI")]
16    pub struct URI(Object<ffi::SpiceURI, ffi::SpiceURIClass>);
17
18    match fn {
19        type_ => || ffi::spice_uri_get_type(),
20    }
21}
22
23impl URI {
24    #[doc(alias = "spice_uri_get_hostname")]
25    #[doc(alias = "get_hostname")]
26    pub fn hostname(&self) -> Option<glib::GString> {
27        unsafe { from_glib_none(ffi::spice_uri_get_hostname(self.to_glib_none().0)) }
28    }
29
30    #[doc(alias = "spice_uri_get_password")]
31    #[doc(alias = "get_password")]
32    pub fn password(&self) -> Option<glib::GString> {
33        unsafe { from_glib_none(ffi::spice_uri_get_password(self.to_glib_none().0)) }
34    }
35
36    #[doc(alias = "spice_uri_get_port")]
37    #[doc(alias = "get_port")]
38    pub fn port(&self) -> u32 {
39        unsafe { ffi::spice_uri_get_port(self.to_glib_none().0) }
40    }
41
42    #[doc(alias = "spice_uri_get_scheme")]
43    #[doc(alias = "get_scheme")]
44    pub fn scheme(&self) -> Option<glib::GString> {
45        unsafe { from_glib_none(ffi::spice_uri_get_scheme(self.to_glib_none().0)) }
46    }
47
48    #[doc(alias = "spice_uri_get_user")]
49    #[doc(alias = "get_user")]
50    pub fn user(&self) -> Option<glib::GString> {
51        unsafe { from_glib_none(ffi::spice_uri_get_user(self.to_glib_none().0)) }
52    }
53
54    #[doc(alias = "spice_uri_set_hostname")]
55    #[doc(alias = "hostname")]
56    pub fn set_hostname(&self, hostname: &str) {
57        unsafe {
58            ffi::spice_uri_set_hostname(self.to_glib_none().0, hostname.to_glib_none().0);
59        }
60    }
61
62    #[doc(alias = "spice_uri_set_password")]
63    #[doc(alias = "password")]
64    pub fn set_password(&self, password: &str) {
65        unsafe {
66            ffi::spice_uri_set_password(self.to_glib_none().0, password.to_glib_none().0);
67        }
68    }
69
70    #[doc(alias = "spice_uri_set_port")]
71    #[doc(alias = "port")]
72    pub fn set_port(&self, port: u32) {
73        unsafe {
74            ffi::spice_uri_set_port(self.to_glib_none().0, port);
75        }
76    }
77
78    #[doc(alias = "spice_uri_set_scheme")]
79    #[doc(alias = "scheme")]
80    pub fn set_scheme(&self, scheme: &str) {
81        unsafe {
82            ffi::spice_uri_set_scheme(self.to_glib_none().0, scheme.to_glib_none().0);
83        }
84    }
85
86    #[doc(alias = "spice_uri_set_user")]
87    #[doc(alias = "user")]
88    pub fn set_user(&self, user: &str) {
89        unsafe {
90            ffi::spice_uri_set_user(self.to_glib_none().0, user.to_glib_none().0);
91        }
92    }
93
94    #[doc(alias = "spice_uri_to_string")]
95    #[doc(alias = "to_string")]
96    pub fn to_str(&self) -> glib::GString {
97        unsafe { from_glib_full(ffi::spice_uri_to_string(self.to_glib_none().0)) }
98    }
99
100    #[doc(alias = "hostname")]
101    pub fn connect_hostname_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
102        unsafe extern "C" fn notify_hostname_trampoline<F: Fn(&URI) + 'static>(
103            this: *mut ffi::SpiceURI,
104            _param_spec: glib::ffi::gpointer,
105            f: glib::ffi::gpointer,
106        ) {
107            unsafe {
108                let f: &F = &*(f as *const F);
109                f(&from_glib_borrow(this))
110            }
111        }
112        unsafe {
113            let f: Box_<F> = Box_::new(f);
114            connect_raw(
115                self.as_ptr() as *mut _,
116                c"notify::hostname".as_ptr(),
117                Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
118                    notify_hostname_trampoline::<F> as *const (),
119                )),
120                Box_::into_raw(f),
121            )
122        }
123    }
124
125    #[doc(alias = "password")]
126    pub fn connect_password_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
127        unsafe extern "C" fn notify_password_trampoline<F: Fn(&URI) + 'static>(
128            this: *mut ffi::SpiceURI,
129            _param_spec: glib::ffi::gpointer,
130            f: glib::ffi::gpointer,
131        ) {
132            unsafe {
133                let f: &F = &*(f as *const F);
134                f(&from_glib_borrow(this))
135            }
136        }
137        unsafe {
138            let f: Box_<F> = Box_::new(f);
139            connect_raw(
140                self.as_ptr() as *mut _,
141                c"notify::password".as_ptr(),
142                Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
143                    notify_password_trampoline::<F> as *const (),
144                )),
145                Box_::into_raw(f),
146            )
147        }
148    }
149
150    #[doc(alias = "port")]
151    pub fn connect_port_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
152        unsafe extern "C" fn notify_port_trampoline<F: Fn(&URI) + 'static>(
153            this: *mut ffi::SpiceURI,
154            _param_spec: glib::ffi::gpointer,
155            f: glib::ffi::gpointer,
156        ) {
157            unsafe {
158                let f: &F = &*(f as *const F);
159                f(&from_glib_borrow(this))
160            }
161        }
162        unsafe {
163            let f: Box_<F> = Box_::new(f);
164            connect_raw(
165                self.as_ptr() as *mut _,
166                c"notify::port".as_ptr(),
167                Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
168                    notify_port_trampoline::<F> as *const (),
169                )),
170                Box_::into_raw(f),
171            )
172        }
173    }
174
175    #[doc(alias = "scheme")]
176    pub fn connect_scheme_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
177        unsafe extern "C" fn notify_scheme_trampoline<F: Fn(&URI) + 'static>(
178            this: *mut ffi::SpiceURI,
179            _param_spec: glib::ffi::gpointer,
180            f: glib::ffi::gpointer,
181        ) {
182            unsafe {
183                let f: &F = &*(f as *const F);
184                f(&from_glib_borrow(this))
185            }
186        }
187        unsafe {
188            let f: Box_<F> = Box_::new(f);
189            connect_raw(
190                self.as_ptr() as *mut _,
191                c"notify::scheme".as_ptr(),
192                Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
193                    notify_scheme_trampoline::<F> as *const (),
194                )),
195                Box_::into_raw(f),
196            )
197        }
198    }
199
200    #[doc(alias = "user")]
201    pub fn connect_user_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
202        unsafe extern "C" fn notify_user_trampoline<F: Fn(&URI) + 'static>(
203            this: *mut ffi::SpiceURI,
204            _param_spec: glib::ffi::gpointer,
205            f: glib::ffi::gpointer,
206        ) {
207            unsafe {
208                let f: &F = &*(f as *const F);
209                f(&from_glib_borrow(this))
210            }
211        }
212        unsafe {
213            let f: Box_<F> = Box_::new(f);
214            connect_raw(
215                self.as_ptr() as *mut _,
216                c"notify::user".as_ptr(),
217                Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
218                    notify_user_trampoline::<F> as *const (),
219                )),
220                Box_::into_raw(f),
221            )
222        }
223    }
224}
225
226impl std::fmt::Display for URI {
227    #[inline]
228    fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
229        f.write_str(&self.to_str())
230    }
231}