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
// 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,Setting};
use glib::{prelude::*,signal::{connect_raw, SignalHandlerId},translate::*};
use std::{boxed::Box as Box_};
glib::wrapper! {
/// Bonding Settings
///
/// ## Properties
///
///
/// #### `options`
/// Dictionary of key/value pairs of bonding options. Both keys and values
/// must be strings. Option names must contain only alphanumeric characters
/// (ie, [a-zA-Z0-9]).
///
/// Readable | Writeable
/// <details><summary><h4>Setting</h4></summary>
///
///
/// #### `name`
/// The setting's name, which uniquely identifies the setting within the
/// connection. Each setting type has a name unique to that type, for
/// example "ppp" or "802-11-wireless" or "802-3-ethernet".
///
/// Readable
/// </details>
///
/// # Implements
///
/// [`SettingExt`][trait@crate::prelude::SettingExt]
#[doc(alias = "NMSettingBond")]
pub struct SettingBond(Object<ffi::NMSettingBond, ffi::NMSettingBondClass>) @extends Setting;
match fn {
type_ => || ffi::nm_setting_bond_get_type(),
}
}
impl SettingBond {
/// Creates a new #NMSettingBond object with default values.
///
/// # Returns
///
/// the new empty #NMSettingBond object
#[doc(alias = "nm_setting_bond_new")]
pub fn new() -> SettingBond {
assert_initialized_main_thread!();
unsafe {
Setting::from_glib_full(ffi::nm_setting_bond_new()).unsafe_cast()
}
}
// rustdoc-stripper-ignore-next
/// Creates a new builder-pattern struct instance to construct [`SettingBond`] objects.
///
/// This method returns an instance of [`SettingBondBuilder`](crate::builders::SettingBondBuilder) which can be used to create [`SettingBond`] objects.
pub fn builder() -> SettingBondBuilder {
SettingBondBuilder::new()
}
/// Add an option to the table. Adding a new name replaces any existing name/value pair
/// that may already exist.
/// ## `name`
/// name for the option
/// ## `value`
/// value for the option
///
/// # Returns
///
/// returns [`false`] if either @name or @value is [`None`], in that case
/// the option is not set. Otherwise, the function does not fail and does not validate
/// the arguments. All validation happens via nm_connection_verify() or do basic validation
/// yourself with nm_setting_bond_validate_option().
///
/// Note: Before 1.30, libnm would perform basic validation of the name and the value
/// via nm_setting_bond_validate_option() and reject the request by returning FALSE.
/// Since 1.30, libnm no longer rejects any values as the setter is not supposed
/// to perform validation.
#[doc(alias = "nm_setting_bond_add_option")]
pub fn add_option(&self, name: &str, value: &str) -> bool {
unsafe {
from_glib(ffi::nm_setting_bond_add_option(self.to_glib_none().0, name.to_glib_none().0, value.to_glib_none().0))
}
}
/// Returns the number of options that should be set for this bond when it
/// is activated. This can be used to retrieve each option individually
/// using nm_setting_bond_get_option().
///
/// # Returns
///
/// the number of bonding options
#[doc(alias = "nm_setting_bond_get_num_options")]
#[doc(alias = "get_num_options")]
pub fn num_options(&self) -> u32 {
unsafe {
ffi::nm_setting_bond_get_num_options(self.to_glib_none().0)
}
}
/// Given an index, return the value of the bonding option at that index. Indexes
/// are *not* guaranteed to be static across modifications to options done by
/// nm_setting_bond_add_option() and nm_setting_bond_remove_option(),
/// and should not be used to refer to options except for short periods of time
/// such as during option iteration.
/// ## `idx`
/// index of the desired option, from 0 to
/// nm_setting_bond_get_num_options() - 1
///
/// # Returns
///
/// [`true`] on success if the index was valid and an option was found,
/// [`false`] if the index was invalid (ie, greater than the number of options
/// currently held by the setting)
///
/// ## `out_name`
/// on return, the name of the bonding option;
/// this value is owned by the setting and should not be modified
///
/// ## `out_value`
/// on return, the value of the name of the
/// bonding option; this value is owned by the setting and should not be
/// modified
#[doc(alias = "nm_setting_bond_get_option")]
#[doc(alias = "get_option")]
pub fn option(&self, idx: u32) -> Option<(glib::GString, glib::GString)> {
unsafe {
let mut out_name = std::ptr::null();
let mut out_value = std::ptr::null();
let ret = from_glib(ffi::nm_setting_bond_get_option(self.to_glib_none().0, idx, &mut out_name, &mut out_value));
if ret { Some((from_glib_none(out_name), from_glib_none(out_value))) } else { None }
}
}
/// Returns the value associated with the bonding option specified by
/// @name, if it exists.
/// ## `name`
/// the option name for which to retrieve the value
///
/// # Returns
///
/// the value, or [`None`] if the key/value pair was never added to the
/// setting; the value is owned by the setting and must not be modified
#[doc(alias = "nm_setting_bond_get_option_by_name")]
#[doc(alias = "get_option_by_name")]
pub fn option_by_name(&self, name: &str) -> glib::GString {
unsafe {
from_glib_none(ffi::nm_setting_bond_get_option_by_name(self.to_glib_none().0, name.to_glib_none().0))
}
}
/// ## `name`
/// the name of the option
///
/// # Returns
///
/// the value of the bond option if not overridden by an entry in
/// the #NMSettingBond:options property.
#[doc(alias = "nm_setting_bond_get_option_default")]
#[doc(alias = "get_option_default")]
pub fn option_default(&self, name: &str) -> glib::GString {
unsafe {
from_glib_none(ffi::nm_setting_bond_get_option_default(self.to_glib_none().0, name.to_glib_none().0))
}
}
/// ## `name`
/// the name of the option
///
/// # Returns
///
/// the value of the bond option after normalization, which is what NetworkManager
/// will actually apply when activating the connection. [`None`] if the option won't be applied
/// to the connection.
#[cfg(feature = "v1_24")]
#[cfg_attr(docsrs, doc(cfg(feature = "v1_24")))]
#[doc(alias = "nm_setting_bond_get_option_normalized")]
#[doc(alias = "get_option_normalized")]
pub fn option_normalized(&self, name: &str) -> glib::GString {
unsafe {
from_glib_none(ffi::nm_setting_bond_get_option_normalized(self.to_glib_none().0, name.to_glib_none().0))
}
}
/// Returns a list of valid bond options.
///
/// The @self argument is unused and may be passed as [`None`].
///
/// # Returns
///
/// a [`None`]-terminated array of strings of valid bond options.
#[doc(alias = "nm_setting_bond_get_valid_options")]
#[doc(alias = "get_valid_options")]
pub fn valid_options(&self) -> Vec<glib::GString> {
unsafe {
FromGlibPtrContainer::from_glib_none(ffi::nm_setting_bond_get_valid_options(self.to_glib_none().0))
}
}
/// Remove the bonding option referenced by @name from the internal option
/// list.
/// ## `name`
/// name of the option to remove
///
/// # Returns
///
/// [`true`] if the option was found and removed from the internal option
/// list, [`false`] if it was not.
#[doc(alias = "nm_setting_bond_remove_option")]
pub fn remove_option(&self, name: &str) -> bool {
unsafe {
from_glib(ffi::nm_setting_bond_remove_option(self.to_glib_none().0, name.to_glib_none().0))
}
}
//pub fn options(&self) -> /*Unimplemented*/HashTable TypeId { ns_id: 0, id: 28 }/TypeId { ns_id: 0, id: 28 } {
// ObjectExt::property(self, "options")
//}
//pub fn set_options(&self, options: /*Unimplemented*/HashTable TypeId { ns_id: 0, id: 28 }/TypeId { ns_id: 0, id: 28 }) {
// ObjectExt::set_property(self,"options", options)
//}
/// Checks whether @name is a valid bond option and @value is a valid value for
/// the @name. If @value is [`None`], the function only validates the option name.
/// ## `name`
/// the name of the option to validate
/// ## `value`
/// the value of the option to validate.
///
/// # Returns
///
/// [`true`], if the @value is valid for the given name.
/// If the @name is not a valid option, [`false`] will be returned.
#[doc(alias = "nm_setting_bond_validate_option")]
pub fn validate_option(name: &str, value: Option<&str>) -> bool {
assert_initialized_main_thread!();
unsafe {
from_glib(ffi::nm_setting_bond_validate_option(name.to_glib_none().0, value.to_glib_none().0))
}
}
#[doc(alias = "options")]
pub fn connect_options_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
unsafe extern "C" fn notify_options_trampoline<F: Fn(&SettingBond) + 'static>(this: *mut ffi::NMSettingBond, _param_spec: glib::ffi::gpointer, f: glib::ffi::gpointer) {
let f: &F = &*(f as *const F);
f(&from_glib_borrow(this))
}
unsafe {
let f: Box_<F> = Box_::new(f);
connect_raw(self.as_ptr() as *mut _, c"notify::options".as_ptr() as *const _,
Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(notify_options_trampoline::<F> as *const ())), Box_::into_raw(f))
}
}
}
impl Default for SettingBond {
fn default() -> Self {
Self::new()
}
}
// rustdoc-stripper-ignore-next
/// A [builder-pattern] type to construct [`SettingBond`] objects.
///
/// [builder-pattern]: https://doc.rust-lang.org/1.0.0/style/ownership/builders.html
#[must_use = "The builder must be built to be used"]
pub struct SettingBondBuilder {
builder: glib::object::ObjectBuilder<'static, SettingBond>,
}
impl SettingBondBuilder {
fn new() -> Self {
Self { builder: glib::object::Object::builder() }
}
//pub fn options(self, options: /*Unimplemented*/HashTable TypeId { ns_id: 0, id: 28 }/TypeId { ns_id: 0, id: 28 }) -> Self {
// Self { builder: self.builder.property("options", options), }
//}
// rustdoc-stripper-ignore-next
/// Build the [`SettingBond`].
#[must_use = "Building the object from the builder is usually expensive and is not expected to have side effects"]
pub fn build(self) -> SettingBond {
assert_initialized_main_thread!();
self.builder.build() }
}