fn generate_unary()

in dubbo-build/src/client.rs [163:193]


fn generate_unary<T: Method>(
    service_unique_name: String,
    method: &T,
    proto_path: &str,
    compile_well_known_types: bool,
    path: String,
) -> TokenStream {
    let codec_name = syn::parse_str::<syn::Path>(CODEC_PATH).unwrap();
    let ident = format_ident!("{}", method.name());
    let (request, response) = method.request_response_name(proto_path, compile_well_known_types);
    let method_name = method.identifier();

    quote! {
        pub async fn #ident(
            &mut self,
            request: Request<#request>,
        ) -> Result<Response<#response>, dubbo::status::Status> {
           let codec = #codec_name::<#request, #response>::default();
           let invocation = RpcInvocation::default()
            .with_service_unique_name(String::from(#service_unique_name))
            .with_method_name(String::from(#method_name));
           let path = http::uri::PathAndQuery::from_static(#path);
           self.inner.unary(
                request,
                codec,
                path,
                invocation,
            ).await
        }
    }
}