use socket2::{Domain, Protocol, Socket, Type}; struct Init; struct Master; struct Backup; impl Init { fn new() -> Init { Init {} } } trait VRRPv2StateMachine { fn next(&self) -> impl VRRPv2StateMachine; } impl VRRPv2StateMachine for Init { fn next(&self) -> impl VRRPv2StateMachine { Master {} } } impl VRRPv2StateMachine for Master { fn next(&self) -> impl VRRPv2StateMachine { Backup {} } } impl VRRPv2StateMachine for Backup { fn next(&self) -> impl VRRPv2StateMachine { Init {} } } fn run() { let sm = Init::new(); loop { let _ = sm.next(); } } fn main() { let res = Socket::new(Domain::IPV4, Type::RAW, Some(Protocol::from(112))); let Ok(_sock) = res else { eprintln!("Socket::new(): {}", res.err().unwrap()); std::process::exit(1); }; }