1use ipnet::IpNet;
2
3use crate::Context;
4
5pub type CallbackResult = Result<(), Box<dyn std::error::Error>>;
7
8pub struct NetConfig<C: Into<NodeConfig>, F: FnOnce(Context) -> CallbackResult> {
13 pub nodes: Vec<C>,
15 pub main: F,
17}
18
19#[derive(Default, Clone)]
21pub struct NodeConfig {
22 pub name: String,
24 pub ifaddr: IpNet,
26}
27
28impl From<String> for NodeConfig {
29 fn from(name: String) -> Self {
30 Self {
31 name,
32 ..Default::default()
33 }
34 }
35}
36
37impl From<&str> for NodeConfig {
38 fn from(name: &str) -> Self {
39 Self {
40 name: name.into(),
41 ..Default::default()
42 }
43 }
44}