From 8c00c0503151cca22fb0635a5f9a54ec93a0e0f7 Mon Sep 17 00:00:00 2001 From: "evgeny.bovykin" Date: Fri, 29 Nov 2024 13:43:23 +0100 Subject: [PATCH] Cleanup: cargo fmt --- volo-build/src/grpc_backend.rs | 55 ++++++++++++++++++++++++-------- volo-build/src/thrift_backend.rs | 2 +- volo-build/src/util.rs | 2 +- 3 files changed, 44 insertions(+), 15 deletions(-) diff --git a/volo-build/src/grpc_backend.rs b/volo-build/src/grpc_backend.rs index fe33fac5..9bfbeba1 100644 --- a/volo-build/src/grpc_backend.rs +++ b/volo-build/src/grpc_backend.rs @@ -1,6 +1,6 @@ -use std::io::Write; -use std::path::Path; +use crate::util::{get_base_dir, write_file, write_item}; use itertools::Itertools; +use pilota_build::middle::context::Mode; use pilota_build::{ db::RirDatabase, rir, @@ -8,9 +8,9 @@ use pilota_build::{ tags::protobuf::{ClientStreaming, ServerStreaming}, CodegenBackend, Context, DefId, IdentName, Symbol, }; -use pilota_build::middle::context::Mode; +use std::io::Write; +use std::path::Path; use volo::FastStr; -use crate::util::{get_base_dir, write_file, write_item}; pub struct MkGrpcBackend; @@ -440,7 +440,7 @@ impl CodegenBackend for VoloGrpcBackend { }}" ); - let req_enum_send_impl = format! { + let req_enum_send_impl = format! { r#" pub enum {req_enum_name_send} {{ {req_enum_send_variants} @@ -604,13 +604,43 @@ impl CodegenBackend for VoloGrpcBackend { if self.cx().split { let mut mod_rs_stream = String::new(); - write_item(&mut mod_rs_stream, base_dir, format!("enum_{}.rs", req_enum_name_send), req_enum_send_impl); - write_item(&mut mod_rs_stream, base_dir, format!("enum_{}.rs", req_enum_name_recv), req_enum_recv_impl); - write_item(&mut mod_rs_stream, base_dir, format!("enum_{}.rs", resp_enum_name_send), resp_enum_send_impl); - write_item(&mut mod_rs_stream, base_dir, format!("enum_{}.rs", resp_enum_name_recv), resp_enum_recv_impl); + write_item( + &mut mod_rs_stream, + base_dir, + format!("enum_{}.rs", req_enum_name_send), + req_enum_send_impl, + ); + write_item( + &mut mod_rs_stream, + base_dir, + format!("enum_{}.rs", req_enum_name_recv), + req_enum_recv_impl, + ); + write_item( + &mut mod_rs_stream, + base_dir, + format!("enum_{}.rs", resp_enum_name_send), + resp_enum_send_impl, + ); + write_item( + &mut mod_rs_stream, + base_dir, + format!("enum_{}.rs", resp_enum_name_recv), + resp_enum_recv_impl, + ); - write_item(&mut mod_rs_stream, base_dir, format!("client_{}.rs", client_name), client_impl); - write_item(&mut mod_rs_stream, base_dir, format!("server_{}.rs", server_name), server_impl); + write_item( + &mut mod_rs_stream, + base_dir, + format!("client_{}.rs", client_name), + client_impl, + ); + write_item( + &mut mod_rs_stream, + base_dir, + format!("server_{}.rs", server_name), + server_impl, + ); let mod_rs_file_path = base_dir.join("mod.rs"); write_file(&mod_rs_file_path, mod_rs_stream); @@ -619,7 +649,7 @@ impl CodegenBackend for VoloGrpcBackend { "include!(\"{}/mod.rs\");", base_dir.file_name().unwrap().to_str().unwrap() ) - .as_str(), + .as_str(), ); } else { stream.push_str(&format! { @@ -635,7 +665,6 @@ impl CodegenBackend for VoloGrpcBackend { } } - fn codegen_service_method(&self, _service_def_id: DefId, method: &rir::Method) -> String { let client_streaming = self .cx() diff --git a/volo-build/src/thrift_backend.rs b/volo-build/src/thrift_backend.rs index 6c509f77..db87b015 100644 --- a/volo-build/src/thrift_backend.rs +++ b/volo-build/src/thrift_backend.rs @@ -1,5 +1,6 @@ use std::{io::Write, path::Path}; +use crate::util::{get_base_dir, write_file, write_item}; use itertools::Itertools; use pilota_build::{ codegen::thrift::DecodeHelper, @@ -11,7 +12,6 @@ use pilota_build::{ }; use quote::format_ident; use volo::FastStr; -use crate::util::{get_base_dir, write_file, write_item}; #[derive(Clone)] pub struct VoloThriftBackend { diff --git a/volo-build/src/util.rs b/volo-build/src/util.rs index cfbde9e9..b2580044 100644 --- a/volo-build/src/util.rs +++ b/volo-build/src/util.rs @@ -912,4 +912,4 @@ pub(crate) fn get_base_dir(mode: &Mode, def_id: Option<&usize>, path: &[Symbol]) }; let base_dir = Path::new(&base_dir); base_dir.to_path_buf() -} \ No newline at end of file +}