nm_rs/auto/
ip_config.rs

1// This file was generated by gir (https://github.com/gtk-rs/gir)
2// from gir
3// from gtk-girs (https://github.com/gtk-rs/gir-files)
4// DO NOT EDIT
5
6use crate::{ffi,IPAddress,IPRoute,Object};
7use glib::{prelude::*,signal::{connect_raw, SignalHandlerId},translate::*};
8use std::{boxed::Box as Box_};
9
10glib::wrapper! {
11    ///
12    ///
13    /// This is an Abstract Base Class, you cannot instantiate it.
14    ///
15    /// ## Properties
16    ///
17    ///
18    /// #### `addresses`
19    ///  A #GPtrArray containing the addresses (#NMIPAddress) of the configuration.
20    ///
21    /// Readable
22    ///
23    ///
24    /// #### `domains`
25    ///  The array containing domain strings of the configuration.
26    ///
27    /// Readable
28    ///
29    ///
30    /// #### `family`
31    ///  The IP address family of the configuration; either
32    /// <literal>AF_INET</literal> or <literal>AF_INET6</literal>.
33    ///
34    /// Readable
35    ///
36    ///
37    /// #### `gateway`
38    ///  The IP gateway address of the configuration as string.
39    ///
40    /// Readable
41    ///
42    ///
43    /// #### `nameservers`
44    ///  The array containing name server IP addresses of the configuration.
45    ///
46    /// Readable
47    ///
48    ///
49    /// #### `routes`
50    ///  A #GPtrArray containing the routes (#NMIPRoute) of the configuration.
51    ///
52    /// Readable
53    ///
54    ///
55    /// #### `searches`
56    ///  The array containing DNS search strings of the configuration.
57    ///
58    /// Readable
59    ///
60    ///
61    /// #### `wins-servers`
62    ///  The array containing WINS server IP addresses of the configuration.
63    /// (This will always be empty for IPv6 configurations.)
64    ///
65    /// Readable
66    /// <details><summary><h4>Object</h4></summary>
67    ///
68    ///
69    /// #### `client`
70    ///  The NMClient instance as returned by nm_object_get_client().
71    ///
72    /// When an NMObject gets removed from the NMClient cache,
73    /// the NMObject:path property stays unchanged, but this client
74    /// instance gets reset to [`None`]. You can use this property to
75    /// track removal of the object from the cache.
76    ///
77    /// Readable
78    ///
79    ///
80    /// #### `path`
81    ///  The D-Bus object path.
82    ///
83    /// The D-Bus path of an object instance never changes, even if the object
84    /// gets removed from the cache. To see whether the object is still in the
85    /// cache, check NMObject:client.
86    ///
87    /// Readable
88    /// </details>
89    ///
90    /// # Implements
91    ///
92    /// [`ObjectExt`][trait@crate::prelude::ObjectExt]
93    #[doc(alias = "NMIPConfig")]
94    pub struct IPConfig(Object<ffi::NMIPConfig, ffi::NMIPConfigClass>) @extends Object;
95
96    match fn {
97        type_ => || ffi::nm_ip_config_get_type(),
98    }
99}
100
101impl IPConfig {
102    /// Gets the IP addresses (containing the address, prefix, and gateway).
103    ///
104    /// # Returns
105    ///
106    /// the #GPtrArray
107    /// containing #NMIPAddress<!-- -->es.  This is the internal copy used by the
108    /// configuration and must not be modified. The library never modifies the
109    /// returned array and thus it is safe for callers to reference and keep using it.
110    #[doc(alias = "nm_ip_config_get_addresses")]
111    #[doc(alias = "get_addresses")]
112    pub fn addresses(&self) -> Vec<IPAddress> {
113        unsafe {
114            FromGlibPtrContainer::from_glib_none(ffi::nm_ip_config_get_addresses(self.to_glib_none().0))
115        }
116    }
117
118    /// Gets the domain names.
119    ///
120    /// # Returns
121    ///
122    /// the array of domains.
123    /// (This is never [`None`], though it may be 0-length).
124    #[doc(alias = "nm_ip_config_get_domains")]
125    #[doc(alias = "get_domains")]
126    pub fn domains(&self) -> Vec<glib::GString> {
127        unsafe {
128            FromGlibPtrContainer::from_glib_none(ffi::nm_ip_config_get_domains(self.to_glib_none().0))
129        }
130    }
131
132    /// Gets the IP address family
133    ///
134    /// # Returns
135    ///
136    /// the IP address family; either <literal>AF_INET</literal> or
137    /// <literal>AF_INET6</literal>
138    #[doc(alias = "nm_ip_config_get_family")]
139    #[doc(alias = "get_family")]
140    pub fn family(&self) -> i32 {
141        unsafe {
142            ffi::nm_ip_config_get_family(self.to_glib_none().0)
143        }
144    }
145
146    /// Gets the IP gateway address.
147    ///
148    /// # Returns
149    ///
150    /// the IP address of the gateway.
151    #[doc(alias = "nm_ip_config_get_gateway")]
152    #[doc(alias = "get_gateway")]
153    pub fn gateway(&self) -> glib::GString {
154        unsafe {
155            from_glib_none(ffi::nm_ip_config_get_gateway(self.to_glib_none().0))
156        }
157    }
158
159    /// Gets the domain name servers (DNS).
160    ///
161    /// # Returns
162    ///
163    /// the array of nameserver IP addresses
164    #[doc(alias = "nm_ip_config_get_nameservers")]
165    #[doc(alias = "get_nameservers")]
166    pub fn nameservers(&self) -> Vec<glib::GString> {
167        unsafe {
168            FromGlibPtrContainer::from_glib_none(ffi::nm_ip_config_get_nameservers(self.to_glib_none().0))
169        }
170    }
171
172    /// Gets the routes.
173    ///
174    /// # Returns
175    ///
176    /// the #GPtrArray containing
177    /// #NMIPRoute<!-- -->s. This is the internal copy used by the configuration, and must
178    /// not be modified. The library never modifies the returned array and thus it is
179    /// safe for callers to reference and keep using it.
180    #[doc(alias = "nm_ip_config_get_routes")]
181    #[doc(alias = "get_routes")]
182    pub fn routes(&self) -> Vec<IPRoute> {
183        unsafe {
184            FromGlibPtrContainer::from_glib_none(ffi::nm_ip_config_get_routes(self.to_glib_none().0))
185        }
186    }
187
188    /// Gets the DNS searches.
189    ///
190    /// # Returns
191    ///
192    /// the array of DNS search strings.
193    /// (This is never [`None`], though it may be 0-length).
194    #[doc(alias = "nm_ip_config_get_searches")]
195    #[doc(alias = "get_searches")]
196    pub fn searches(&self) -> Vec<glib::GString> {
197        unsafe {
198            FromGlibPtrContainer::from_glib_none(ffi::nm_ip_config_get_searches(self.to_glib_none().0))
199        }
200    }
201
202    /// Gets the Windows Internet Name Service servers (WINS).
203    ///
204    /// # Returns
205    ///
206    /// the arry of WINS server IP address strings.
207    /// (This is never [`None`], though it may be 0-length.)
208    #[doc(alias = "nm_ip_config_get_wins_servers")]
209    #[doc(alias = "get_wins_servers")]
210    #[doc(alias = "wins-servers")]
211    pub fn wins_servers(&self) -> Vec<glib::GString> {
212        unsafe {
213            FromGlibPtrContainer::from_glib_none(ffi::nm_ip_config_get_wins_servers(self.to_glib_none().0))
214        }
215    }
216
217    #[doc(alias = "addresses")]
218    pub fn connect_addresses_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
219        unsafe extern "C" fn notify_addresses_trampoline<F: Fn(&IPConfig) + 'static>(this: *mut ffi::NMIPConfig, _param_spec: glib::ffi::gpointer, f: glib::ffi::gpointer) {
220            let f: &F = &*(f as *const F);
221            f(&from_glib_borrow(this))
222        }
223        unsafe {
224            let f: Box_<F> = Box_::new(f);
225            connect_raw(self.as_ptr() as *mut _, c"notify::addresses".as_ptr() as *const _,
226                Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(notify_addresses_trampoline::<F> as *const ())), Box_::into_raw(f))
227        }
228    }
229
230    #[doc(alias = "domains")]
231    pub fn connect_domains_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
232        unsafe extern "C" fn notify_domains_trampoline<F: Fn(&IPConfig) + 'static>(this: *mut ffi::NMIPConfig, _param_spec: glib::ffi::gpointer, f: glib::ffi::gpointer) {
233            let f: &F = &*(f as *const F);
234            f(&from_glib_borrow(this))
235        }
236        unsafe {
237            let f: Box_<F> = Box_::new(f);
238            connect_raw(self.as_ptr() as *mut _, c"notify::domains".as_ptr() as *const _,
239                Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(notify_domains_trampoline::<F> as *const ())), Box_::into_raw(f))
240        }
241    }
242
243    #[doc(alias = "family")]
244    pub fn connect_family_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
245        unsafe extern "C" fn notify_family_trampoline<F: Fn(&IPConfig) + 'static>(this: *mut ffi::NMIPConfig, _param_spec: glib::ffi::gpointer, f: glib::ffi::gpointer) {
246            let f: &F = &*(f as *const F);
247            f(&from_glib_borrow(this))
248        }
249        unsafe {
250            let f: Box_<F> = Box_::new(f);
251            connect_raw(self.as_ptr() as *mut _, c"notify::family".as_ptr() as *const _,
252                Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(notify_family_trampoline::<F> as *const ())), Box_::into_raw(f))
253        }
254    }
255
256    #[doc(alias = "gateway")]
257    pub fn connect_gateway_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
258        unsafe extern "C" fn notify_gateway_trampoline<F: Fn(&IPConfig) + 'static>(this: *mut ffi::NMIPConfig, _param_spec: glib::ffi::gpointer, f: glib::ffi::gpointer) {
259            let f: &F = &*(f as *const F);
260            f(&from_glib_borrow(this))
261        }
262        unsafe {
263            let f: Box_<F> = Box_::new(f);
264            connect_raw(self.as_ptr() as *mut _, c"notify::gateway".as_ptr() as *const _,
265                Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(notify_gateway_trampoline::<F> as *const ())), Box_::into_raw(f))
266        }
267    }
268
269    #[doc(alias = "nameservers")]
270    pub fn connect_nameservers_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
271        unsafe extern "C" fn notify_nameservers_trampoline<F: Fn(&IPConfig) + 'static>(this: *mut ffi::NMIPConfig, _param_spec: glib::ffi::gpointer, f: glib::ffi::gpointer) {
272            let f: &F = &*(f as *const F);
273            f(&from_glib_borrow(this))
274        }
275        unsafe {
276            let f: Box_<F> = Box_::new(f);
277            connect_raw(self.as_ptr() as *mut _, c"notify::nameservers".as_ptr() as *const _,
278                Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(notify_nameservers_trampoline::<F> as *const ())), Box_::into_raw(f))
279        }
280    }
281
282    #[doc(alias = "routes")]
283    pub fn connect_routes_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
284        unsafe extern "C" fn notify_routes_trampoline<F: Fn(&IPConfig) + 'static>(this: *mut ffi::NMIPConfig, _param_spec: glib::ffi::gpointer, f: glib::ffi::gpointer) {
285            let f: &F = &*(f as *const F);
286            f(&from_glib_borrow(this))
287        }
288        unsafe {
289            let f: Box_<F> = Box_::new(f);
290            connect_raw(self.as_ptr() as *mut _, c"notify::routes".as_ptr() as *const _,
291                Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(notify_routes_trampoline::<F> as *const ())), Box_::into_raw(f))
292        }
293    }
294
295    #[doc(alias = "searches")]
296    pub fn connect_searches_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
297        unsafe extern "C" fn notify_searches_trampoline<F: Fn(&IPConfig) + 'static>(this: *mut ffi::NMIPConfig, _param_spec: glib::ffi::gpointer, f: glib::ffi::gpointer) {
298            let f: &F = &*(f as *const F);
299            f(&from_glib_borrow(this))
300        }
301        unsafe {
302            let f: Box_<F> = Box_::new(f);
303            connect_raw(self.as_ptr() as *mut _, c"notify::searches".as_ptr() as *const _,
304                Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(notify_searches_trampoline::<F> as *const ())), Box_::into_raw(f))
305        }
306    }
307
308    #[doc(alias = "wins-servers")]
309    pub fn connect_wins_servers_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
310        unsafe extern "C" fn notify_wins_servers_trampoline<F: Fn(&IPConfig) + 'static>(this: *mut ffi::NMIPConfig, _param_spec: glib::ffi::gpointer, f: glib::ffi::gpointer) {
311            let f: &F = &*(f as *const F);
312            f(&from_glib_borrow(this))
313        }
314        unsafe {
315            let f: Box_<F> = Box_::new(f);
316            connect_raw(self.as_ptr() as *mut _, c"notify::wins-servers".as_ptr() as *const _,
317                Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(notify_wins_servers_trampoline::<F> as *const ())), Box_::into_raw(f))
318        }
319    }
320}