mod actions;
mod events;
mod hooks;
mod types;
use std::str::FromStr;
pub use hooks::DaitaHooks;
use maybenot::Machine;
pub mod api {
#[derive(Debug, Clone)]
pub struct DaitaSettings {
pub maybenot_machines: Vec<String>,
pub max_padding_frac: f64,
pub max_blocking_frac: f64,
pub max_blocked_packets: usize,
pub min_blocking_capacity: usize,
}
}
#[derive(Debug, Clone)]
pub struct DaitaSettings {
pub maybenot_machines: Vec<Machine>,
pub max_padding_frac: f64,
pub max_blocking_frac: f64,
pub max_blocked_packets: usize,
pub min_blocking_capacity: usize,
}
impl TryFrom<api::DaitaSettings> for DaitaSettings {
type Error = crate::device::Error;
fn try_from(value: api::DaitaSettings) -> Result<Self, Self::Error> {
Ok(DaitaSettings {
maybenot_machines: value
.maybenot_machines
.iter()
.map(|s| Machine::from_str(s))
.collect::<Result<Vec<_>, _>>()?,
max_padding_frac: value.max_padding_frac,
max_blocking_frac: value.max_blocking_frac,
max_blocked_packets: value.max_blocked_packets,
min_blocking_capacity: value.min_blocking_capacity,
})
}
}