diff --git a/src/{{crate_name}}_impl.rs b/src/{{crate_name}}_impl.rs index d50bd88..95f5124 100644 --- a/src/{{crate_name}}_impl.rs +++ b/src/{{crate_name}}_impl.rs @@ -1,17 +1,19 @@ -use crate::{{service_name}}::{{service_name}}_service_server::{{service_name | pascal_case}}ServiceServer; -use crate::{{service_name}}::{{"{"}}{{service_name}}_service_server::{{service_name | pascal_case}}Service, {{service_name | pascal_case}}Request, {{service_name | pascal_case}}Response}; +use crate::{{crate_name}}::{{crate_name}}_service_server::{{crate_name | pascal_case}}ServiceServer; +use crate::{{crate_name}}::{{crate_name}}_service_server::{{crate_name | pascal_case}}Service; +use crate::{{crate_name}}::{{crate_name | pascal_case}}Request; +use crate::{{crate_name}}::{{crate_name | pascal_case}}Response; use std::error::Error; use tonic::{Request, Response, Status}; use tonic_reflection::server::{Builder, ServerReflection, ServerReflectionServer}; -const FILE_DESCRIPTOR_SET: &[u8] = include_bytes!("{{service_name}}_reflection_descriptor.bin"); +const FILE_DESCRIPTOR_SET: &[u8] = include_bytes!("reflection_descriptor.bin"); #[derive(Default)] -pub struct {{service_name | pascal_case}}ServiceImpl {} +pub struct {{crate_name | pascal_case}}ServiceImpl {} -impl {{service_name | pascal_case}}ServiceImpl { - pub fn new() -> {{service_name | pascal_case}}ServiceServer<{{service_name | pascal_case}}ServiceImpl> { - {{service_name | pascal_case}}ServiceServer::new({{service_name | pascal_case}}ServiceImpl {}) +impl {{crate_name | pascal_case}}ServiceImpl { + pub fn new() -> {{crate_name | pascal_case}}ServiceServer<{{crate_name | pascal_case}}ServiceImpl> { + {{crate_name | pascal_case}}ServiceServer::new({{crate_name | pascal_case}}ServiceImpl {}) } pub fn attach_reflection() -> Result, Box> { Builder::configure() @@ -22,10 +24,10 @@ impl {{service_name | pascal_case}}ServiceImpl { } #[tonic::async_trait] -impl {{service_name | pascal_case}}Service for {{service_name | pascal_case}}ServiceImpl { - async fn {{rpc_method}}(&self, request: Request<{{service_name | pascal_case}}Request>) -> Result, Status> { +impl {{crate_name | pascal_case}}Service for {{crate_name | pascal_case}}ServiceImpl { + async fn {{rpc_method}}(&self, request: Request<{{crate_name | pascal_case}}Request>) -> Result, Status> { let name = request.into_inner().name; - let reply = {{service_name | pascal_case}}Response { + let reply = {{crate_name | pascal_case}}Response { message: format!("Hello {}!", name), }; Ok(Response::new(reply))