1use crate::{ffi};
7#[cfg(feature = "v1_14")]
8#[cfg_attr(docsrs, doc(cfg(feature = "v1_14")))]
9use crate::{SriovVFVlanProtocol};
10#[cfg(feature = "v1_14")]
11#[cfg_attr(docsrs, doc(cfg(feature = "v1_14")))]
12use glib::{translate::*};
13
14glib::wrapper! {
15 #[derive(Debug, PartialOrd, Ord, Hash)]
16 pub struct SriovVF(Shared<ffi::NMSriovVF>);
17
18 match fn {
19 ref => |ptr| ffi::nm_sriov_vf_ref(ptr),
20 unref => |ptr| ffi::nm_sriov_vf_unref(ptr),
21 type_ => || ffi::nm_sriov_vf_get_type(),
22 }
23}
24
25impl SriovVF {
26 #[cfg(feature = "v1_14")]
34 #[cfg_attr(docsrs, doc(cfg(feature = "v1_14")))]
35 #[doc(alias = "nm_sriov_vf_new")]
36 pub fn new(index: u32) -> SriovVF {
37 assert_initialized_main_thread!();
38 unsafe {
39 from_glib_full(ffi::nm_sriov_vf_new(index))
40 }
41 }
42
43 #[cfg(feature = "v1_14")]
51 #[cfg_attr(docsrs, doc(cfg(feature = "v1_14")))]
52 #[doc(alias = "nm_sriov_vf_add_vlan")]
53 pub fn add_vlan(&self, vlan_id: u32) -> bool {
54 unsafe {
55 from_glib(ffi::nm_sriov_vf_add_vlan(self.to_glib_none().0, vlan_id))
56 }
57 }
58
59 #[cfg(feature = "v1_14")]
65 #[cfg_attr(docsrs, doc(cfg(feature = "v1_14")))]
66 #[doc(alias = "nm_sriov_vf_dup")]
67#[must_use]
68 pub fn dup(&self) -> SriovVF {
69 unsafe {
70 from_glib_full(ffi::nm_sriov_vf_dup(self.to_glib_none().0))
71 }
72 }
73
74 #[cfg(feature = "v1_14")]
75 #[cfg_attr(docsrs, doc(cfg(feature = "v1_14")))]
76 #[doc(alias = "nm_sriov_vf_equal")]
77 fn equal(&self, other: &SriovVF) -> bool {
78 unsafe {
79 from_glib(ffi::nm_sriov_vf_equal(self.to_glib_none().0, other.to_glib_none().0))
80 }
81 }
82
83 #[cfg(feature = "v1_14")]
97 #[cfg_attr(docsrs, doc(cfg(feature = "v1_14")))]
98 #[doc(alias = "nm_sriov_vf_get_attribute_names")]
99 #[doc(alias = "get_attribute_names")]
100 pub fn attribute_names(&self) -> Vec<glib::GString> {
101 unsafe {
102 FromGlibPtrContainer::from_glib_container(ffi::nm_sriov_vf_get_attribute_names(self.to_glib_none().0))
103 }
104 }
105
106 #[cfg(feature = "v1_14")]
112 #[cfg_attr(docsrs, doc(cfg(feature = "v1_14")))]
113 #[doc(alias = "nm_sriov_vf_get_index")]
114 #[doc(alias = "get_index")]
115 pub fn index(&self) -> u32 {
116 unsafe {
117 ffi::nm_sriov_vf_get_index(self.to_glib_none().0)
118 }
119 }
120
121 #[cfg(feature = "v1_14")]
128 #[cfg_attr(docsrs, doc(cfg(feature = "v1_14")))]
129 #[doc(alias = "nm_sriov_vf_get_vlan_ids")]
130 #[doc(alias = "get_vlan_ids")]
131 pub fn vlan_ids(&self) -> Vec<u32> {
132 unsafe {
133 let mut length = std::mem::MaybeUninit::uninit();
134 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 _);
135 ret
136 }
137 }
138
139 #[cfg(feature = "v1_14")]
147 #[cfg_attr(docsrs, doc(cfg(feature = "v1_14")))]
148 #[doc(alias = "nm_sriov_vf_get_vlan_protocol")]
149 #[doc(alias = "get_vlan_protocol")]
150 pub fn vlan_protocol(&self, vlan_id: u32) -> SriovVFVlanProtocol {
151 unsafe {
152 from_glib(ffi::nm_sriov_vf_get_vlan_protocol(self.to_glib_none().0, vlan_id))
153 }
154 }
155
156 #[cfg(feature = "v1_14")]
164 #[cfg_attr(docsrs, doc(cfg(feature = "v1_14")))]
165 #[doc(alias = "nm_sriov_vf_get_vlan_qos")]
166 #[doc(alias = "get_vlan_qos")]
167 pub fn vlan_qos(&self, vlan_id: u32) -> u32 {
168 unsafe {
169 ffi::nm_sriov_vf_get_vlan_qos(self.to_glib_none().0, vlan_id)
170 }
171 }
172
173 #[cfg(feature = "v1_14")]
182 #[cfg_attr(docsrs, doc(cfg(feature = "v1_14")))]
183 #[doc(alias = "nm_sriov_vf_remove_vlan")]
184 pub fn remove_vlan(&self, vlan_id: u32) -> bool {
185 unsafe {
186 from_glib(ffi::nm_sriov_vf_remove_vlan(self.to_glib_none().0, vlan_id))
187 }
188 }
189
190 #[cfg(feature = "v1_14")]
203 #[cfg_attr(docsrs, doc(cfg(feature = "v1_14")))]
204 #[doc(alias = "nm_sriov_vf_set_vlan_protocol")]
205 pub fn set_vlan_protocol(&self, vlan_id: u32, protocol: SriovVFVlanProtocol) {
206 unsafe {
207 ffi::nm_sriov_vf_set_vlan_protocol(self.to_glib_none().0, vlan_id, protocol.into_glib());
208 }
209 }
210
211 #[cfg(feature = "v1_14")]
217 #[cfg_attr(docsrs, doc(cfg(feature = "v1_14")))]
218 #[doc(alias = "nm_sriov_vf_set_vlan_qos")]
219 pub fn set_vlan_qos(&self, vlan_id: u32, qos: u32) {
220 unsafe {
221 ffi::nm_sriov_vf_set_vlan_qos(self.to_glib_none().0, vlan_id, qos);
222 }
223 }
224
225 }
232
233#[cfg(feature = "v1_14")]
234#[cfg_attr(docsrs, doc(cfg(feature = "v1_14")))]
235impl PartialEq for SriovVF {
236 #[inline]
237 fn eq(&self, other: &Self) -> bool {
238 self.equal(other)
239 }
240}
241#[cfg(feature = "v1_14")]
242#[cfg_attr(docsrs, doc(cfg(feature = "v1_14")))]
243
244impl Eq for SriovVF {}