diff --git a/src/case_study.rs b/src/case_study.rs index 6724a84..d67bd6d 100644 --- a/src/case_study.rs +++ b/src/case_study.rs @@ -113,6 +113,29 @@ impl Active { event_attr!(id, Uuid, id); } + +impl From> for Active { + fn from(pending: Event) -> Active { + Active::Pending(pending) + } +} + +macro_rules! from_event { + ($t:ty, $variant:ident) => { + impl From> for Active { + fn from(event: Event<$t>) -> Active { + Active::$variant(event) + } + } + } +} + +//from_event!(Pending, Pending); +from_event!(Sending, Sending); +from_event!(Sent, Sent); +from_event!(Ack, Acked); +from_event!(Finished, FinishedNoAck); + #[allow(unused)] #[cfg(test)] mod tests {