nm_rs/auto/
sriov_vf.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};
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    /// Creates a new #NMSriovVF object.
27    /// ## `index`
28    /// the VF index
29    ///
30    /// # Returns
31    ///
32    /// the new #NMSriovVF object.
33    #[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    /// Adds a VLAN to the VF. Currently kernel only supports one VLAN per VF.
44    /// ## `vlan_id`
45    /// the VLAN id
46    ///
47    /// # Returns
48    ///
49    /// [`true`] if the VLAN was added; [`false`] if it already existed
50    #[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    /// Creates a copy of @self.
60    ///
61    /// # Returns
62    ///
63    /// a copy of @self
64    #[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")]
84    //#[cfg_attr(docsrs, doc(cfg(feature = "v1_14")))]
85    //#[doc(alias = "nm_sriov_vf_get_attribute")]
86    //#[doc(alias = "get_attribute")]
87    //pub fn attribute(&self, name: &str) -> /*Ignored*/glib::Variant {
88    //    unsafe { TODO: call ffi:nm_sriov_vf_get_attribute() }
89    //}
90
91    /// Gets an array of attribute names defined on @self.
92    ///
93    /// # Returns
94    ///
95    /// a [`None`]-terminated array of attribute names
96    #[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    /// Gets the index property of this VF object.
107    ///
108    /// # Returns
109    ///
110    /// the VF index
111    #[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    /// Returns the VLANs currently configured on the VF. Currently kernel only
122    /// supports one VLAN per VF.
123    ///
124    /// # Returns
125    ///
126    /// a list of VLAN ids configured on the VF.
127    #[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    /// Returns the configured protocol for the given VLAN.
140    /// ## `vlan_id`
141    /// the VLAN id
142    ///
143    /// # Returns
144    ///
145    /// the configured protocol
146    #[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    /// Returns the QoS value for the given VLAN.
157    /// ## `vlan_id`
158    /// the VLAN id
159    ///
160    /// # Returns
161    ///
162    /// the QoS value
163    #[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    /// Removes a VLAN from a VF.
174    /// ## `vlan_id`
175    /// the VLAN id
176    ///
177    /// # Returns
178    ///
179    /// [`true`] if the VLAN was removed, [`false`] if the VLAN @vlan_id
180    ///     did not belong to the VF.
181    #[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")]
191    //#[cfg_attr(docsrs, doc(cfg(feature = "v1_14")))]
192    //#[doc(alias = "nm_sriov_vf_set_attribute")]
193    //pub fn set_attribute(&self, name: &str, value: /*Ignored*/Option<&glib::Variant>) {
194    //    unsafe { TODO: call ffi:nm_sriov_vf_set_attribute() }
195    //}
196
197    /// Sets the protocol for the given VLAN.
198    /// ## `vlan_id`
199    /// the VLAN id
200    /// ## `protocol`
201    /// the VLAN protocol
202    #[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    /// Sets a QoS value for the given VLAN.
212    /// ## `vlan_id`
213    /// the VLAN id
214    /// ## `qos`
215    /// a QoS (priority) value
216    #[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    //#[cfg(feature = "v1_42")]
226    //#[cfg_attr(docsrs, doc(cfg(feature = "v1_42")))]
227    //#[doc(alias = "nm_sriov_vf_attribute_validate")]
228    //pub fn attribute_validate(name: &str, value: /*Ignored*/&glib::Variant) -> Result<bool, glib::Error> {
229    //    unsafe { TODO: call ffi:nm_sriov_vf_attribute_validate() }
230    //}
231}
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 {}