rtnetlink/link/
handle.rs

1// SPDX-License-Identifier: MIT
2
3use super::{
4    BondPortSetRequest, LinkAddRequest, LinkDelPropRequest, LinkDelRequest,
5    LinkGetRequest, LinkNewPropRequest, LinkSetRequest,
6};
7use crate::Handle;
8
9pub struct LinkHandle(Handle);
10
11impl LinkHandle {
12    pub fn new(handle: Handle) -> Self {
13        LinkHandle(handle)
14    }
15
16    pub fn set(&self, index: u32) -> LinkSetRequest {
17        LinkSetRequest::new(self.0.clone(), index)
18    }
19
20    pub fn add(&self) -> LinkAddRequest {
21        LinkAddRequest::new(self.0.clone())
22    }
23
24    pub fn property_add(&self, index: u32) -> LinkNewPropRequest {
25        LinkNewPropRequest::new(self.0.clone(), index)
26    }
27
28    pub fn property_del(&self, index: u32) -> LinkDelPropRequest {
29        LinkDelPropRequest::new(self.0.clone(), index)
30    }
31
32    pub fn del(&mut self, index: u32) -> LinkDelRequest {
33        LinkDelRequest::new(self.0.clone(), index)
34    }
35
36    /// Retrieve the list of links (equivalent to `ip link show`)
37    pub fn get(&mut self) -> LinkGetRequest {
38        LinkGetRequest::new(self.0.clone())
39    }
40
41    pub fn set_bond_port(&mut self, index: u32) -> BondPortSetRequest {
42        BondPortSetRequest::new(self.0.clone(), index)
43    }
44}