Skip to content

Commit

Permalink
fix typo
Browse files Browse the repository at this point in the history
  • Loading branch information
codeitlikemiley committed Dec 17, 2023
1 parent 4a92bd7 commit 535757d
Showing 1 changed file with 12 additions and 10 deletions.
22 changes: 12 additions & 10 deletions src/{{crate_name}}_impl.rs
Original file line number Diff line number Diff line change
@@ -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<ServerReflectionServer<impl ServerReflection + 'static>, Box<dyn Error>> {
Builder::configure()
Expand All @@ -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<Response<{{service_name | pascal_case}}Response>, 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<Response<{{crate_name | pascal_case}}Response>, 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))
Expand Down

0 comments on commit 535757d

Please sign in to comment.