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
// 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_14")]
#[cfg_attr(docsrs, doc(cfg(feature = "v1_14")))]
use crate::{SriovVFVlanProtocol};
#[cfg(feature = "v1_14")]
#[cfg_attr(docsrs, doc(cfg(feature = "v1_14")))]
use glib::{translate::*};
glib::wrapper! {
#[derive(Debug, PartialOrd, Ord, Hash)]
pub struct SriovVF(Shared<ffi::NMSriovVF>);
match fn {
ref => |ptr| ffi::nm_sriov_vf_ref(ptr),
unref => |ptr| ffi::nm_sriov_vf_unref(ptr),
type_ => || ffi::nm_sriov_vf_get_type(),
}
}
impl SriovVF {
/// Creates a new #NMSriovVF object.
/// ## `index`
/// the VF index
///
/// # Returns
///
/// the new #NMSriovVF object.
#[cfg(feature = "v1_14")]
#[cfg_attr(docsrs, doc(cfg(feature = "v1_14")))]
#[doc(alias = "nm_sriov_vf_new")]
pub fn new(index: u32) -> SriovVF {
assert_initialized_main_thread!();
unsafe {
from_glib_full(ffi::nm_sriov_vf_new(index))
}
}
/// Adds a VLAN to the VF. Currently kernel only supports one VLAN per VF.
/// ## `vlan_id`
/// the VLAN id
///
/// # Returns
///
/// [`true`] if the VLAN was added; [`false`] if it already existed
#[cfg(feature = "v1_14")]
#[cfg_attr(docsrs, doc(cfg(feature = "v1_14")))]
#[doc(alias = "nm_sriov_vf_add_vlan")]
pub fn add_vlan(&self, vlan_id: u32) -> bool {
unsafe {
from_glib(ffi::nm_sriov_vf_add_vlan(self.to_glib_none().0, vlan_id))
}
}
/// Creates a copy of @self.
///
/// # Returns
///
/// a copy of @self
#[cfg(feature = "v1_14")]
#[cfg_attr(docsrs, doc(cfg(feature = "v1_14")))]
#[doc(alias = "nm_sriov_vf_dup")]
#[must_use]
pub fn dup(&self) -> SriovVF {
unsafe {
from_glib_full(ffi::nm_sriov_vf_dup(self.to_glib_none().0))
}
}
#[cfg(feature = "v1_14")]
#[cfg_attr(docsrs, doc(cfg(feature = "v1_14")))]
#[doc(alias = "nm_sriov_vf_equal")]
fn equal(&self, other: &SriovVF) -> bool {
unsafe {
from_glib(ffi::nm_sriov_vf_equal(self.to_glib_none().0, other.to_glib_none().0))
}
}
//#[cfg(feature = "v1_14")]
//#[cfg_attr(docsrs, doc(cfg(feature = "v1_14")))]
//#[doc(alias = "nm_sriov_vf_get_attribute")]
//#[doc(alias = "get_attribute")]
//pub fn attribute(&self, name: &str) -> /*Ignored*/glib::Variant {
// unsafe { TODO: call ffi:nm_sriov_vf_get_attribute() }
//}
/// Gets an array of attribute names defined on @self.
///
/// # Returns
///
/// a [`None`]-terminated array of attribute names
#[cfg(feature = "v1_14")]
#[cfg_attr(docsrs, doc(cfg(feature = "v1_14")))]
#[doc(alias = "nm_sriov_vf_get_attribute_names")]
#[doc(alias = "get_attribute_names")]
pub fn attribute_names(&self) -> Vec<glib::GString> {
unsafe {
FromGlibPtrContainer::from_glib_container(ffi::nm_sriov_vf_get_attribute_names(self.to_glib_none().0))
}
}
/// Gets the index property of this VF object.
///
/// # Returns
///
/// the VF index
#[cfg(feature = "v1_14")]
#[cfg_attr(docsrs, doc(cfg(feature = "v1_14")))]
#[doc(alias = "nm_sriov_vf_get_index")]
#[doc(alias = "get_index")]
pub fn index(&self) -> u32 {
unsafe {
ffi::nm_sriov_vf_get_index(self.to_glib_none().0)
}
}
/// Returns the VLANs currently configured on the VF. Currently kernel only
/// supports one VLAN per VF.
///
/// # Returns
///
/// a list of VLAN ids configured on the VF.
#[cfg(feature = "v1_14")]
#[cfg_attr(docsrs, doc(cfg(feature = "v1_14")))]
#[doc(alias = "nm_sriov_vf_get_vlan_ids")]
#[doc(alias = "get_vlan_ids")]
pub fn vlan_ids(&self) -> Vec<u32> {
unsafe {
let mut length = std::mem::MaybeUninit::uninit();
let ret = FromGlibContainer::from_glib_none_num(ffi::nm_sriov_vf_get_vlan_ids(self.to_glib_none().0, length.as_mut_ptr()), length.assume_init() as _);
ret
}
}
/// Returns the configured protocol for the given VLAN.
/// ## `vlan_id`
/// the VLAN id
///
/// # Returns
///
/// the configured protocol
#[cfg(feature = "v1_14")]
#[cfg_attr(docsrs, doc(cfg(feature = "v1_14")))]
#[doc(alias = "nm_sriov_vf_get_vlan_protocol")]
#[doc(alias = "get_vlan_protocol")]
pub fn vlan_protocol(&self, vlan_id: u32) -> SriovVFVlanProtocol {
unsafe {
from_glib(ffi::nm_sriov_vf_get_vlan_protocol(self.to_glib_none().0, vlan_id))
}
}
/// Returns the QoS value for the given VLAN.
/// ## `vlan_id`
/// the VLAN id
///
/// # Returns
///
/// the QoS value
#[cfg(feature = "v1_14")]
#[cfg_attr(docsrs, doc(cfg(feature = "v1_14")))]
#[doc(alias = "nm_sriov_vf_get_vlan_qos")]
#[doc(alias = "get_vlan_qos")]
pub fn vlan_qos(&self, vlan_id: u32) -> u32 {
unsafe {
ffi::nm_sriov_vf_get_vlan_qos(self.to_glib_none().0, vlan_id)
}
}
/// Removes a VLAN from a VF.
/// ## `vlan_id`
/// the VLAN id
///
/// # Returns
///
/// [`true`] if the VLAN was removed, [`false`] if the VLAN @vlan_id
/// did not belong to the VF.
#[cfg(feature = "v1_14")]
#[cfg_attr(docsrs, doc(cfg(feature = "v1_14")))]
#[doc(alias = "nm_sriov_vf_remove_vlan")]
pub fn remove_vlan(&self, vlan_id: u32) -> bool {
unsafe {
from_glib(ffi::nm_sriov_vf_remove_vlan(self.to_glib_none().0, vlan_id))
}
}
//#[cfg(feature = "v1_14")]
//#[cfg_attr(docsrs, doc(cfg(feature = "v1_14")))]
//#[doc(alias = "nm_sriov_vf_set_attribute")]
//pub fn set_attribute(&self, name: &str, value: /*Ignored*/Option<&glib::Variant>) {
// unsafe { TODO: call ffi:nm_sriov_vf_set_attribute() }
//}
/// Sets the protocol for the given VLAN.
/// ## `vlan_id`
/// the VLAN id
/// ## `protocol`
/// the VLAN protocol
#[cfg(feature = "v1_14")]
#[cfg_attr(docsrs, doc(cfg(feature = "v1_14")))]
#[doc(alias = "nm_sriov_vf_set_vlan_protocol")]
pub fn set_vlan_protocol(&self, vlan_id: u32, protocol: SriovVFVlanProtocol) {
unsafe {
ffi::nm_sriov_vf_set_vlan_protocol(self.to_glib_none().0, vlan_id, protocol.into_glib());
}
}
/// Sets a QoS value for the given VLAN.
/// ## `vlan_id`
/// the VLAN id
/// ## `qos`
/// a QoS (priority) value
#[cfg(feature = "v1_14")]
#[cfg_attr(docsrs, doc(cfg(feature = "v1_14")))]
#[doc(alias = "nm_sriov_vf_set_vlan_qos")]
pub fn set_vlan_qos(&self, vlan_id: u32, qos: u32) {
unsafe {
ffi::nm_sriov_vf_set_vlan_qos(self.to_glib_none().0, vlan_id, qos);
}
}
//#[cfg(feature = "v1_42")]
//#[cfg_attr(docsrs, doc(cfg(feature = "v1_42")))]
//#[doc(alias = "nm_sriov_vf_attribute_validate")]
//pub fn attribute_validate(name: &str, value: /*Ignored*/&glib::Variant) -> Result<bool, glib::Error> {
// unsafe { TODO: call ffi:nm_sriov_vf_attribute_validate() }
//}
}
#[cfg(feature = "v1_14")]
#[cfg_attr(docsrs, doc(cfg(feature = "v1_14")))]
impl PartialEq for SriovVF {
#[inline]
fn eq(&self, other: &Self) -> bool {
self.equal(other)
}
}
#[cfg(feature = "v1_14")]
#[cfg_attr(docsrs, doc(cfg(feature = "v1_14")))]
impl Eq for SriovVF {}