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
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
// This file was generated by gir (https://github.com/gtk-rs/gir)
// from gir
// from gtk-girs (https://github.com/gtk-rs/gir-files)
// DO NOT EDIT
use crate::{ffi};
#[cfg(feature = "v1_8")]
#[cfg_attr(docsrs, doc(cfg(feature = "v1_8")))]
use crate::{VariantAttributeSpec};
use glib::{translate::*};
glib::wrapper! {
#[derive(Debug, PartialOrd, Ord, Hash)]
pub struct IPRoute(Shared<ffi::NMIPRoute>);
match fn {
ref => |ptr| ffi::nm_ip_route_ref(ptr),
unref => |ptr| ffi::nm_ip_route_unref(ptr),
type_ => || ffi::nm_ip_route_get_type(),
}
}
impl IPRoute {
/// Creates a new #NMIPRoute object.
/// ## `family`
/// the IP address family (<literal>AF_INET</literal> or
/// <literal>AF_INET6</literal>)
/// ## `dest`
/// the IP address of the route's destination
/// ## `prefix`
/// the address prefix length
/// ## `next_hop`
/// the IP address of the next hop (or [`None`])
/// ## `metric`
/// the route metric (or -1 for "default")
///
/// # Returns
///
/// the new #NMIPRoute object, or [`None`] on error
#[doc(alias = "nm_ip_route_new")]
pub fn new(family: i32, dest: &str, prefix: u32, next_hop: Option<&str>, metric: i64) -> Result<IPRoute, glib::Error> {
assert_initialized_main_thread!();
unsafe {
let mut error = std::ptr::null_mut();
let ret = ffi::nm_ip_route_new(family, dest.to_glib_none().0, prefix, next_hop.to_glib_none().0, metric, &mut error);
if error.is_null() { Ok(from_glib_full(ret)) } else { Err(from_glib_full(error)) }
}
}
//#[doc(alias = "nm_ip_route_new_binary")]
//pub fn new_binary(family: i32, dest: /*Unimplemented*/Option<Basic: Pointer>, prefix: u32, next_hop: /*Unimplemented*/Option<Basic: Pointer>, metric: i64) -> Result<IPRoute, glib::Error> {
// unsafe { TODO: call ffi:nm_ip_route_new_binary() }
//}
/// Creates a copy of @self
///
/// # Returns
///
/// a copy of @self
///
/// This API was part of public headers before 1.32.0 but
/// was erroneously not exported in the ABI. It is thus only
/// usable since 1.32.0.
#[cfg(feature = "v1_32")]
#[cfg_attr(docsrs, doc(cfg(feature = "v1_32")))]
#[doc(alias = "nm_ip_route_dup")]
#[must_use]
pub fn dup(&self) -> IPRoute {
unsafe {
from_glib_full(ffi::nm_ip_route_dup(self.to_glib_none().0))
}
}
#[doc(alias = "nm_ip_route_equal")]
fn equal(&self, other: &IPRoute) -> bool {
unsafe {
from_glib(ffi::nm_ip_route_equal(self.to_glib_none().0, other.to_glib_none().0))
}
}
/// Determines if two #NMIPRoute objects contain the same destination, prefix,
/// next hop, and metric.
/// ## `other`
/// the #NMIPRoute to compare @self to.
/// ## `cmp_flags`
/// tune how to compare attributes. Currently, only
/// NM_IP_ROUTE_EQUAL_CMP_FLAGS_NONE (0) and NM_IP_ROUTE_EQUAL_CMP_FLAGS_WITH_ATTRS (1)
/// is supported.
///
/// # Returns
///
/// [`true`] if the objects contain the same values, [`false`] if they do not.
#[cfg(feature = "v1_10")]
#[cfg_attr(docsrs, doc(cfg(feature = "v1_10")))]
#[doc(alias = "nm_ip_route_equal_full")]
pub fn equal_full(&self, other: &IPRoute, cmp_flags: u32) -> bool {
unsafe {
from_glib(ffi::nm_ip_route_equal_full(self.to_glib_none().0, other.to_glib_none().0, cmp_flags))
}
}
//#[doc(alias = "nm_ip_route_get_attribute")]
//#[doc(alias = "get_attribute")]
//pub fn attribute(&self, name: &str) -> /*Ignored*/glib::Variant {
// unsafe { TODO: call ffi:nm_ip_route_get_attribute() }
//}
/// Gets an array of attribute names defined on @self.
///
/// # Returns
///
/// a [`None`]-terminated array of attribute names
#[doc(alias = "nm_ip_route_get_attribute_names")]
#[doc(alias = "get_attribute_names")]
pub fn attribute_names(&self) -> Vec<glib::GString> {
unsafe {
FromGlibPtrContainer::from_glib_full(ffi::nm_ip_route_get_attribute_names(self.to_glib_none().0))
}
}
/// Gets the IP destination address property of this route object.
///
/// # Returns
///
/// the IP address of the route's destination
#[doc(alias = "nm_ip_route_get_dest")]
#[doc(alias = "get_dest")]
pub fn dest(&self) -> glib::GString {
unsafe {
from_glib_none(ffi::nm_ip_route_get_dest(self.to_glib_none().0))
}
}
//#[doc(alias = "nm_ip_route_get_dest_binary")]
//#[doc(alias = "get_dest_binary")]
//pub fn dest_binary(&self, dest: /*Unimplemented*/Option<Basic: Pointer>) {
// unsafe { TODO: call ffi:nm_ip_route_get_dest_binary() }
//}
/// Gets the IP address family (eg, AF_INET) property of this route
/// object.
///
/// # Returns
///
/// the IP address family
#[doc(alias = "nm_ip_route_get_family")]
#[doc(alias = "get_family")]
pub fn family(&self) -> i32 {
unsafe {
ffi::nm_ip_route_get_family(self.to_glib_none().0)
}
}
/// Gets the route metric property of this route object; lower values
/// indicate "better" or more preferred routes; -1 indicates "default"
/// (meaning NetworkManager will set it appropriately).
///
/// # Returns
///
/// the route metric
#[doc(alias = "nm_ip_route_get_metric")]
#[doc(alias = "get_metric")]
pub fn metric(&self) -> i64 {
unsafe {
ffi::nm_ip_route_get_metric(self.to_glib_none().0)
}
}
/// Gets the IP address of the next hop of this route; this will be [`None`] if the
/// route has no next hop.
///
/// # Returns
///
/// the IP address of the next hop, or [`None`] if this is a device route.
#[doc(alias = "nm_ip_route_get_next_hop")]
#[doc(alias = "get_next_hop")]
pub fn next_hop(&self) -> glib::GString {
unsafe {
from_glib_none(ffi::nm_ip_route_get_next_hop(self.to_glib_none().0))
}
}
//#[doc(alias = "nm_ip_route_get_next_hop_binary")]
//#[doc(alias = "get_next_hop_binary")]
//pub fn is_next_hop_binary(&self, next_hop: /*Unimplemented*/Option<Basic: Pointer>) -> bool {
// unsafe { TODO: call ffi:nm_ip_route_get_next_hop_binary() }
//}
/// Gets the IP prefix (ie "24" or "30" etc) of this route.
///
/// # Returns
///
/// the IP prefix
#[doc(alias = "nm_ip_route_get_prefix")]
#[doc(alias = "get_prefix")]
pub fn prefix(&self) -> u32 {
unsafe {
ffi::nm_ip_route_get_prefix(self.to_glib_none().0)
}
}
//#[doc(alias = "nm_ip_route_set_attribute")]
//pub fn set_attribute(&self, name: &str, value: /*Ignored*/Option<&glib::Variant>) {
// unsafe { TODO: call ffi:nm_ip_route_set_attribute() }
//}
/// Sets the destination property of this route object.
///
/// @dest must be a valid address of @self's family. If you aren't sure you
/// have a valid address, use nm_inet_is_valid() to check it.
/// ## `dest`
/// the route's destination, as a string
#[doc(alias = "nm_ip_route_set_dest")]
pub fn set_dest(&self, dest: &str) {
unsafe {
ffi::nm_ip_route_set_dest(self.to_glib_none().0, dest.to_glib_none().0);
}
}
//#[doc(alias = "nm_ip_route_set_dest_binary")]
//pub fn set_dest_binary(&self, dest: /*Unimplemented*/Option<Basic: Pointer>) {
// unsafe { TODO: call ffi:nm_ip_route_set_dest_binary() }
//}
/// Sets the metric property of this route object.
/// ## `metric`
/// the route metric (or -1 for "default")
#[doc(alias = "nm_ip_route_set_metric")]
pub fn set_metric(&self, metric: i64) {
unsafe {
ffi::nm_ip_route_set_metric(self.to_glib_none().0, metric);
}
}
/// Sets the next-hop property of this route object.
///
/// @next_hop (if non-[`None`]) must be a valid address of @self's family. If you
/// aren't sure you have a valid address, use nm_utils_ipaddr_valid() to check
/// it.
/// ## `next_hop`
/// the route's next hop, as a string
#[doc(alias = "nm_ip_route_set_next_hop")]
pub fn set_next_hop(&self, next_hop: Option<&str>) {
unsafe {
ffi::nm_ip_route_set_next_hop(self.to_glib_none().0, next_hop.to_glib_none().0);
}
}
//#[doc(alias = "nm_ip_route_set_next_hop_binary")]
//pub fn set_next_hop_binary(&self, next_hop: /*Unimplemented*/Option<Basic: Pointer>) {
// unsafe { TODO: call ffi:nm_ip_route_set_next_hop_binary() }
//}
/// Sets the prefix property of this route object.
/// ## `prefix`
/// the route prefix
#[doc(alias = "nm_ip_route_set_prefix")]
pub fn set_prefix(&self, prefix: u32) {
unsafe {
ffi::nm_ip_route_set_prefix(self.to_glib_none().0, prefix);
}
}
//#[cfg(feature = "v1_8")]
//#[cfg_attr(docsrs, doc(cfg(feature = "v1_8")))]
//#[doc(alias = "nm_ip_route_attribute_validate")]
//pub fn attribute_validate(name: &str, value: /*Ignored*/&glib::Variant, family: i32) -> Result<bool, glib::Error> {
// unsafe { TODO: call ffi:nm_ip_route_attribute_validate() }
//}
///
/// # Returns
///
/// the specifiers for route attributes
#[cfg(feature = "v1_8")]
#[cfg_attr(docsrs, doc(cfg(feature = "v1_8")))]
#[doc(alias = "nm_ip_route_get_variant_attribute_spec")]
#[doc(alias = "get_variant_attribute_spec")]
pub fn variant_attribute_spec() -> VariantAttributeSpec {
assert_initialized_main_thread!();
unsafe {
from_glib_none(ffi::nm_ip_route_get_variant_attribute_spec())
}
}
}
impl PartialEq for IPRoute {
#[inline]
fn eq(&self, other: &Self) -> bool {
self.equal(other)
}
}
impl Eq for IPRoute {}