Generate dispatch code from macro impl_stubs.

This commit is contained in:
Gav
2018-02-07 21:30:54 +01:00
parent 692770e03f
commit 652b5705d6
3 changed files with 11 additions and 18 deletions
+10 -1
View File
@@ -131,7 +131,16 @@ pub fn print<T: Printable + Sized>(value: T) {
#[macro_export]
macro_rules! impl_stubs {
($( $name:ident ),*) => {}
($( $name:ident ),*) => {
pub fn dispatch(method: &str, data: &[u8]) -> Option<Vec<u8>> {
match method {
$(
stringify!($name) => Some($name(data)),
)*
_ => None,
}
}
}
}
#[cfg(test)]