rtnetlink/link/
bond_port.rs1use crate::{
4 packet_route::link::{InfoBondPort, InfoPortData, InfoPortKind},
5 LinkMessageBuilder,
6};
7
8#[derive(Debug)]
9pub struct LinkBondPort;
10
11impl LinkBondPort {
12 pub fn new(port_index: u32) -> LinkMessageBuilder<Self> {
13 LinkMessageBuilder::<LinkBondPort>::default()
14 .index(port_index)
15 .set_port_kind(InfoPortKind::Bond)
16 }
17}
18
19impl LinkMessageBuilder<LinkBondPort> {
20 pub fn append_info_data(self, info: InfoBondPort) -> Self {
22 let mut ret = self;
23
24 if let InfoPortData::BondPort(infos) = ret
25 .port_data
26 .get_or_insert_with(|| InfoPortData::BondPort(Vec::new()))
27 {
28 infos.push(info);
29 }
30
31 ret
32 }
33
34 pub fn queue_id(self, queue_id: u16) -> Self {
38 self.append_info_data(InfoBondPort::QueueId(queue_id))
39 }
40
41 pub fn prio(self, prio: i32) -> Self {
44 self.append_info_data(InfoBondPort::Prio(prio))
45 }
46}