use crate::{
packet_route::link::{InfoBondPort, InfoPortData, InfoPortKind},
LinkMessageBuilder,
};
#[derive(Debug)]
pub struct LinkBondPort;
impl LinkBondPort {
pub fn new(port_index: u32) -> LinkMessageBuilder<Self> {
LinkMessageBuilder::<LinkBondPort>::default()
.index(port_index)
.set_port_kind(InfoPortKind::Bond)
}
}
impl LinkMessageBuilder<LinkBondPort> {
pub fn append_info_data(self, info: InfoBondPort) -> Self {
let mut ret = self;
if let InfoPortData::BondPort(infos) = ret
.port_data
.get_or_insert_with(|| InfoPortData::BondPort(Vec::new()))
{
infos.push(info);
}
ret
}
pub fn queue_id(self, queue_id: u16) -> Self {
self.append_info_data(InfoBondPort::QueueId(queue_id))
}
pub fn prio(self, prio: i32) -> Self {
self.append_info_data(InfoBondPort::Prio(prio))
}
}