macro_rules! repr_impl {
($repr:ty { $($msg:ty : ( $lift:expr, $pattern:pat => $x:expr ) ),+ }) => { ... };
}
Expand description
The repr_impl
macro creates Repr
implementations for a type used on the wire,
for each protocol message type enumerated in the call.
The macro call consists of <wrapper-type-name>
, followed by lines of:
<raw-type-name>: ( <fn-raw-to-repr> , <pattern-match-repr> => <captured-raw> )
.
§Example
use async_session_types::*;
struct Foo(pub u8);
struct Bar(pub String);
enum Message {
Foo(Foo),
Bar(Bar),
}
repr_impl! {
Message {
Foo: ( Message::Foo, Message::Foo(x) => x ),
Bar: ( |x| Message::Bar(x), Message::Bar(x) => x )
}
}
Note that there’s no comma after the last item!