pub trait Payloads {
type Read;
type Write;
}
pub enum FileOp<P: Payloads> {
Read(P::Read),
Write(P::Write),
}
pub struct Inputs;
impl Payloads for Inputs {
type Read = ();
type Write = u8;
}
pub type Request = FileOp<Inputs>;
pub struct Outputs;
impl Payloads for Outputs {
type Read = u8;
type Write = ();
}
pub type Reply = FileOp<Outputs>;
pub fn execute(request: Request) -> Reply {
match request {
Request::Read(()) => Reply::Read(42),
Request::Write(_) => Reply::Write(()),
}
}
This looks like it would handle synchronizing multiple variant records/enums, and if you just wanted the "plain" enum without any payload, you'd need to do:
Correct? So you'd need to create it with BareFileOp::Read(()), but at least it wouldn't carry any overhead of actually containing data.