"impaqt" writes: >> (3) Make each each VmRequest case a newtype, like so: >> >> #[derive(MsgOnSocket, Debug)] >> pub enum VmRequest { >> Exit(Exit), >> Suspend(Suspend), >> ... >> } >> >> This would basically be a workaround for the fact that enum variants in >> Rust aren't proper types. If they were, though (which we can emulate >> through this approach), we could have some trait with an associated >> socket type for executing each type of request. > > The machine crate might make this option a bit less annoying: > https://github.com/rust-bakery/machine That does look good. Feels like a bit of a shame the machine!() macro isn't its own crate with a more generic name, because I'm sure there are all sorts of situations in which that's useful. As it is, I'd feel a bit concerned about depending on a crate about state machines to define some enums, because that could be very confusing for somebody reading the code.