fn generate_dispatch_function(impls: &[ItemImpl]) -> Result<TokenStream> {
	let data = Ident::new("data", Span::call_site());
	let impl_calls = generate_impl_calls(impls, &data)?
		.into_iter()
		.map(|(trait_, fn_name, impl_)| {
			let name = prefix_function_with_trait(&trait_, &fn_name);
			quote!( #name => Some({ #impl_ }), )
		});

	Ok(quote!(
		#[cfg(feature = "std")]
		pub fn dispatch(method: &str, mut #data: &[u8]) -> Option<Vec<u8>> {
			match method {
				#( #impl_calls )*
				_ => None,
			}
		}
	))
}
/// Generate the dispatch function that is used in native to call into the runtime.
Generate the dispatch function that is used in native to call into the runtime.
Generate the dispatch function that is used in native to call into the runtime .
fn generate_dispatch_function(impls: &[ItemImpl]) -> Result<TokenStream> {
	let data = Ident::new("data", Span::call_site());
	let impl_calls = generate_impl_calls(impls, &data)?
		.into_iter()
		.map(|(trait_, fn_name, impl_)| {
			let name = prefix_function_with_trait(&trait_, &fn_name);
			quote!( #name => Some({ #impl_ }), )
		});
	Ok(quote!(
		#[cfg(feature = "std")]
		pub fn dispatch(method: &str, mut #data: &[u8]) -> Option<Vec<u8>> {
			match method {
				#( #impl_calls )*
				_ => None,
			}
		}
	))
}
fn generate_dispatch_function ( impls : & [ ItemImpl ] ) -> Result < TokenStream > { let data = Ident :: new ( " " , Span :: call_site ( ) ) ; let impl_calls = generate_impl_calls ( impls , & data ) ? . into_iter ( ) . map ( | ( trait_ , fn_name , impl_ ) | { let name = prefix_function_with_trait ( & trait_ , & fn_name ) ; quote ! ( name Some ( { impl_ } ) ) } ) ; Ok ( quote ! ( [ cfg ( feature " " ) ] pub fn dispatch ( method str mut data [ u8 ] ) Option Vec u8 { match method { ( impl_calls ) None } } ) ) }
Generate the dispatch function that is used in native to call into the runtime.
Generate the dispatch function that is used in native to call into the runtime .
impls
&[ItemImpl]
impls
&[ItemImpl]