This is an automated email from the ASF dual-hosted git repository. liujun pushed a commit to branch main in repository https://gitbox.apache.org/repos/asf/dubbo-rust.git
commit fd2ff6d554a1ec9357f2ecb444c122399c4099a1 Author: yang <[email protected]> AuthorDate: Mon Jun 27 21:37:01 2022 +0800 refactor(dubbo): use cargo fmt --all --- dubbo/src/common/mod.rs | 2 +- dubbo/src/common/url.rs | 4 +- dubbo/src/helloworld/client.rs | 2 +- dubbo/src/helloworld/helloworld.rs | 87 +++++++++++++-------------------- dubbo/src/helloworld/mod.rs | 2 +- dubbo/src/lib.rs | 4 +- dubbo/src/main.rs | 5 +- dubbo/src/service/grpc/grpc_exporter.rs | 22 ++++----- dubbo/src/service/grpc/grpc_invoker.rs | 28 +++++------ dubbo/src/service/grpc/grpc_protocol.rs | 15 +++--- dubbo/src/service/grpc/grpc_server.rs | 51 ++++++++++--------- dubbo/src/service/grpc/mod.rs | 49 ++++++++++++------- dubbo/src/service/invocation.rs | 10 ++-- dubbo/src/service/mod.rs | 3 +- dubbo/src/service/protocol.rs | 5 +- dubbo/src/utils/boxed.rs | 2 +- dubbo/src/utils/boxed_clone.rs | 15 ++++-- dubbo/src/utils/mod.rs | 2 +- 18 files changed, 148 insertions(+), 160 deletions(-) diff --git a/dubbo/src/common/mod.rs b/dubbo/src/common/mod.rs index aff8e30..591151d 100644 --- a/dubbo/src/common/mod.rs +++ b/dubbo/src/common/mod.rs @@ -1 +1 @@ -pub mod url; \ No newline at end of file +pub mod url; diff --git a/dubbo/src/common/url.rs b/dubbo/src/common/url.rs index 879a1a0..6d4958d 100644 --- a/dubbo/src/common/url.rs +++ b/dubbo/src/common/url.rs @@ -1,5 +1,5 @@ #[derive(Debug, Clone)] pub struct Url { pub url: String, - pub service_key: String -} \ No newline at end of file + pub service_key: String, +} diff --git a/dubbo/src/helloworld/client.rs b/dubbo/src/helloworld/client.rs index f4517b4..591e382 100644 --- a/dubbo/src/helloworld/client.rs +++ b/dubbo/src/helloworld/client.rs @@ -20,4 +20,4 @@ async fn main() -> Result<(), Box<dyn std::error::Error>> { println!("RESPONSE={:?}", response); Ok(()) -} \ No newline at end of file +} diff --git a/dubbo/src/helloworld/helloworld.rs b/dubbo/src/helloworld/helloworld.rs index b951157..41eb5d9 100644 --- a/dubbo/src/helloworld/helloworld.rs +++ b/dubbo/src/helloworld/helloworld.rs @@ -1,13 +1,13 @@ /// The request message containing the user's name. #[derive(Clone, PartialEq, ::prost::Message)] pub struct HelloRequest { - #[prost(string, tag="1")] + #[prost(string, tag = "1")] pub name: ::prost::alloc::string::String, } /// The response message containing the greetings #[derive(Clone, PartialEq, ::prost::Message)] pub struct HelloReply { - #[prost(string, tag="1")] + #[prost(string, tag = "1")] pub message: ::prost::alloc::string::String, } /// Generated client implementations. @@ -54,9 +54,8 @@ pub mod greeter_client { <T as tonic::client::GrpcService<tonic::body::BoxBody>>::ResponseBody, >, >, - <T as tonic::codegen::Service< - http::Request<tonic::body::BoxBody>, - >>::Error: Into<StdError> + Send + Sync, + <T as tonic::codegen::Service<http::Request<tonic::body::BoxBody>>>::Error: + Into<StdError> + Send + Sync, { GreeterClient::new(InterceptedService::new(inner, interceptor)) } @@ -80,19 +79,14 @@ pub mod greeter_client { &mut self, request: impl tonic::IntoRequest<super::HelloRequest>, ) -> Result<tonic::Response<super::HelloReply>, tonic::Status> { - self.inner - .ready() - .await - .map_err(|e| { - tonic::Status::new( - tonic::Code::Unknown, - format!("Service was not ready: {}", e.into()), - ) - })?; + self.inner.ready().await.map_err(|e| { + tonic::Status::new( + tonic::Code::Unknown, + format!("Service was not ready: {}", e.into()), + ) + })?; let codec = tonic::codec::ProstCodec::default(); - let path = http::uri::PathAndQuery::from_static( - "/helloworld.Greeter/SayHello", - ); + let path = http::uri::PathAndQuery::from_static("/helloworld.Greeter/SayHello"); self.inner.unary(request.into_request(), path, codec).await } } @@ -101,10 +95,10 @@ pub mod greeter_client { pub mod greeter_server { #![allow(unused_variables, dead_code, missing_docs, clippy::let_unit_value)] - use tonic::codegen::*; - use crate::service::protocol::Invoker; use crate::service::grpc::grpc_server::DubboGrpcService; use crate::service::grpc::grpc_server::ServiceDesc; + use crate::service::protocol::Invoker; + use tonic::codegen::*; ///Generated trait containing gRPC methods that should be implemented for use with GreeterServer. #[async_trait] @@ -137,10 +131,7 @@ pub mod greeter_server { send_compression_encodings: Default::default(), } } - pub fn with_interceptor<F>( - inner: T, - interceptor: F, - ) -> InterceptedService<Self, F> + pub fn with_interceptor<F>(inner: T, interceptor: F) -> InterceptedService<Self, F> where F: tonic::service::Interceptor, { @@ -168,10 +159,7 @@ pub mod greeter_server { type Response = http::Response<tonic::body::BoxBody>; type Error = std::convert::Infallible; type Future = BoxFuture<Self::Response, Self::Error>; - fn poll_ready( - &mut self, - _cx: &mut Context<'_>, - ) -> Poll<Result<(), Self::Error>> { + fn poll_ready(&mut self, _cx: &mut Context<'_>) -> Poll<Result<(), Self::Error>> { Poll::Ready(Ok(())) } fn call(&mut self, req: http::Request<B>) -> Self::Future { @@ -180,13 +168,9 @@ pub mod greeter_server { "/helloworld.Greeter/SayHello" => { #[allow(non_camel_case_types)] struct SayHelloSvc<T: Greeter>(pub Arc<T>); - impl<T: Greeter> tonic::server::UnaryService<super::HelloRequest> - for SayHelloSvc<T> { + impl<T: Greeter> tonic::server::UnaryService<super::HelloRequest> for SayHelloSvc<T> { type Response = super::HelloReply; - type Future = BoxFuture< - tonic::Response<Self::Response>, - tonic::Status, - >; + type Future = BoxFuture<tonic::Response<Self::Response>, tonic::Status>; fn call( &mut self, request: tonic::Request<super::HelloRequest>, @@ -203,32 +187,27 @@ pub mod greeter_server { let inner = inner.0; let method = SayHelloSvc(inner); let codec = tonic::codec::ProstCodec::default(); - let mut grpc = tonic::server::Grpc::new(codec) - .apply_compression_config( - accept_compression_encodings, - send_compression_encodings, - ); + let mut grpc = tonic::server::Grpc::new(codec).apply_compression_config( + accept_compression_encodings, + send_compression_encodings, + ); let res = grpc.unary(method, req).await; Ok(res) }; Box::pin(fut) } - _ => { - Box::pin(async move { - Ok( - http::Response::builder() - .status(200) - .header("grpc-status", "12") - .header("content-type", "application/grpc") - .body(empty_body()) - .unwrap(), - ) - }) - } + _ => Box::pin(async move { + Ok(http::Response::builder() + .status(200) + .header("grpc-status", "12") + .header("content-type", "application/grpc") + .body(empty_body()) + .unwrap()) + }), } } } - impl<T: Greeter, I: Invoker+ Send+ Sync + 'static> Clone for GreeterServer<T, I> { + impl<T: Greeter, I: Invoker + Send + Sync + 'static> Clone for GreeterServer<T, I> { fn clone(&self) -> Self { let inner = self.inner.clone(); Self { @@ -243,7 +222,6 @@ pub mod greeter_server { send_compression_encodings: self.send_compression_encodings, } } - } impl<T: Greeter> Clone for _Inner<T> { @@ -262,7 +240,10 @@ pub mod greeter_server { } fn service_desc(&self) -> ServiceDesc { - ServiceDesc::new("helloworld.Greeter".to_string(), std::collections::HashMap::new()) + ServiceDesc::new( + "helloworld.Greeter".to_string(), + std::collections::HashMap::new(), + ) } } diff --git a/dubbo/src/helloworld/mod.rs b/dubbo/src/helloworld/mod.rs index 5f1509d..b1358dd 100644 --- a/dubbo/src/helloworld/mod.rs +++ b/dubbo/src/helloworld/mod.rs @@ -1 +1 @@ -pub mod helloworld; \ No newline at end of file +pub mod helloworld; diff --git a/dubbo/src/lib.rs b/dubbo/src/lib.rs index 317ed6f..0e5bedf 100644 --- a/dubbo/src/lib.rs +++ b/dubbo/src/lib.rs @@ -1,4 +1,4 @@ +pub mod common; pub mod helloworld; pub mod service; -pub mod common; -pub mod utils; \ No newline at end of file +pub mod utils; diff --git a/dubbo/src/main.rs b/dubbo/src/main.rs index ecc7b56..4bb2acf 100644 --- a/dubbo/src/main.rs +++ b/dubbo/src/main.rs @@ -1,10 +1,9 @@ -pub mod service; pub mod common; -pub mod utils; pub mod helloworld; +pub mod service; +pub mod utils; #[tokio::main] async fn main() { println!("hello, dubbo-rust~") } - diff --git a/dubbo/src/service/grpc/grpc_exporter.rs b/dubbo/src/service/grpc/grpc_exporter.rs index 4f367f2..7671b6d 100644 --- a/dubbo/src/service/grpc/grpc_exporter.rs +++ b/dubbo/src/service/grpc/grpc_exporter.rs @@ -1,9 +1,8 @@ - +use crate::service::protocol::Invoker; use crate::service::protocol::*; -use crate::service::protocol::Invoker; pub struct GrpcExporter<T> { - invoker: T + invoker: T, } impl<T> GrpcExporter<T> { @@ -12,23 +11,20 @@ impl<T> GrpcExporter<T> { } } -impl<T: Invoker+Clone> Exporter for GrpcExporter<T> -{ +impl<T: Invoker + Clone> Exporter for GrpcExporter<T> { type InvokerType = T; - fn unexport(&self) { - } + fn unexport(&self) {} fn get_invoker(&self) -> Self::InvokerType { self.invoker.clone() } - } -impl<T: Invoker+Clone> Clone for GrpcExporter<T> { - +impl<T: Invoker + Clone> Clone for GrpcExporter<T> { fn clone(&self) -> Self { - Self { invoker: self.invoker.clone() } + Self { + invoker: self.invoker.clone(), + } } - -} \ No newline at end of file +} diff --git a/dubbo/src/service/grpc/grpc_invoker.rs b/dubbo/src/service/grpc/grpc_invoker.rs index 6016914..3fbd442 100644 --- a/dubbo/src/service/grpc/grpc_invoker.rs +++ b/dubbo/src/service/grpc/grpc_invoker.rs @@ -4,41 +4,35 @@ use tonic::client::Grpc; use tonic::transport::Channel; use tonic::transport::Endpoint; -use crate::service::protocol::*; -use crate::service::invocation; use crate::common::url::Url; +use crate::service::invocation; +use crate::service::protocol::*; pub struct GrpcInvoker { client: Grpc<Channel>, url: Url, - once: Once + once: Once, } - - impl GrpcInvoker { pub fn new(url: Url) -> GrpcInvoker { - let endpoint = Endpoint::new(url.url.clone()).unwrap(); let conn = endpoint.connect_lazy(); Self { url, client: Grpc::new(conn), - once: Once::new() + once: Once::new(), } } } impl Invoker for GrpcInvoker { - fn is_available(&self) -> bool { true } fn destroy(&self) { - self.once.call_once(|| { - println!("destroy...") - }) + self.once.call_once(|| println!("destroy...")) } fn get_url(&self) -> Url { @@ -46,7 +40,7 @@ impl Invoker for GrpcInvoker { } // 根据req中的数据发起req,由Client发起请求,获取响应 - fn invoke<M1>(&self, req: invocation::Request<M1>) -> invocation::Response<String> + fn invoke<M1>(&self, req: invocation::Request<M1>) -> invocation::Response<String> where M1: Send + 'static, { @@ -54,7 +48,7 @@ impl Invoker for GrpcInvoker { let resp = invocation::Response::new("string"); let (_resp_meta, msg) = resp.into_parts(); - + invocation::Response::from_parts(metadata, msg.to_string()) } } @@ -68,6 +62,10 @@ impl Invoker for GrpcInvoker { impl Clone for GrpcInvoker { fn clone(&self) -> Self { - Self { client: self.client.clone(), url: self.url.clone(), once: Once::new() } + Self { + client: self.client.clone(), + url: self.url.clone(), + once: Once::new(), + } } -} \ No newline at end of file +} diff --git a/dubbo/src/service/grpc/grpc_protocol.rs b/dubbo/src/service/grpc/grpc_protocol.rs index 08fe921..8fe1aa8 100644 --- a/dubbo/src/service/grpc/grpc_protocol.rs +++ b/dubbo/src/service/grpc/grpc_protocol.rs @@ -1,15 +1,14 @@ - use std::collections::HashMap; -use super::grpc_invoker::GrpcInvoker; use super::grpc_exporter::GrpcExporter; +use super::grpc_invoker::GrpcInvoker; +use super::grpc_server::GrpcServer; use crate::common::url::Url; use crate::service::protocol::Protocol; -use super::grpc_server::GrpcServer; pub struct GrpcProtocol { server_map: HashMap<String, GrpcServer>, - export_map: HashMap<String, GrpcExporter<GrpcInvoker>> + export_map: HashMap<String, GrpcExporter<GrpcInvoker>>, } impl GrpcProtocol { @@ -28,8 +27,7 @@ impl Default for GrpcProtocol { } #[async_trait::async_trait] -impl Protocol for GrpcProtocol -{ +impl Protocol for GrpcProtocol { type Invoker = GrpcInvoker; type Exporter = GrpcExporter<Self::Invoker>; @@ -45,7 +43,8 @@ impl Protocol for GrpcProtocol async fn export(self, url: Url) -> Self::Exporter { let service_key = url.service_key.clone(); - let exporter: GrpcExporter<GrpcInvoker> = GrpcExporter::new(service_key.clone(), GrpcInvoker::new(url.clone())); + let exporter: GrpcExporter<GrpcInvoker> = + GrpcExporter::new(service_key.clone(), GrpcInvoker::new(url.clone())); let mut export = self.export_map; export.insert(service_key.clone(), exporter.clone()); @@ -57,4 +56,4 @@ impl Protocol for GrpcProtocol server.serve(url.clone()).await; exporter } -} \ No newline at end of file +} diff --git a/dubbo/src/service/grpc/grpc_server.rs b/dubbo/src/service/grpc/grpc_server.rs index 1047054..9d2656e 100644 --- a/dubbo/src/service/grpc/grpc_server.rs +++ b/dubbo/src/service/grpc/grpc_server.rs @@ -2,20 +2,18 @@ use std::collections::HashMap; use std::task::Context; use std::task::Poll; +use tonic::codegen::BoxFuture; use tonic::transport; -use tower::Service; use tonic::transport::NamedService; -use tonic::codegen::BoxFuture; - +use tower::Service; +use super::grpc_invoker::GrpcInvoker; use crate::common::url::Url; use crate::helloworld::helloworld::greeter_server::GreeterServer; -use super::grpc_invoker::GrpcInvoker; use crate::helloworld::helloworld::greeter_server::*; use crate::utils::boxed_clone::BoxCloneService; -pub trait DubboGrpcService<T> -{ +pub trait DubboGrpcService<T> { fn set_proxy_impl(&mut self, invoker: T); fn service_desc(&self) -> ServiceDesc; } @@ -35,7 +33,7 @@ pub struct ServiceDesc { // methods: HashMap<String, String> // "/Greeter/hello": "unary" } -impl ServiceDesc { +impl ServiceDesc { pub fn new(service_name: String, _methods: HashMap<String, String>) -> Self { Self { service_name } } @@ -46,7 +44,9 @@ impl ServiceDesc { } // codegen -pub fn register_greeter_server<T: Greeter>(server: T) -> (super::GrpcBoxCloneService, super::DubboGrpcBox) { +pub fn register_greeter_server<T: Greeter>( + server: T, +) -> (super::GrpcBoxCloneService, super::DubboGrpcBox) { let hello = GreeterServer::<T, GrpcInvoker>::new(server); (BoxCloneService::new(hello.clone()), Box::new(hello.clone())) } @@ -58,36 +58,39 @@ pub struct GrpcServer { name: String, } -impl GrpcServer -{ +impl GrpcServer { pub fn new(name: String) -> GrpcServer { Self { inner: transport::Server::builder(), - name + name, } } - pub async fn serve(mut self, url: Url) - where - { + pub async fn serve(mut self, url: Url) { let addr = url.url.clone().parse().unwrap(); - let svc = super::GRPC_SERVICES.read().unwrap().get(self.name.as_str()).unwrap().clone(); + let svc = super::GRPC_SERVICES + .read() + .unwrap() + .get(self.name.as_str()) + .unwrap() + .clone(); println!("server{:?} start...", url); - self.inner.add_service(MakeSvc::new(svc)).serve( - addr - ).await.unwrap(); + self.inner + .add_service(MakeSvc::new(svc)) + .serve(addr) + .await + .unwrap(); println!("server{:?} start...", url); } - } struct MakeSvc<T, U, E> { - inner: BoxCloneService<T, U, E> + inner: BoxCloneService<T, U, E>, } impl<T, U, E> MakeSvc<T, U, E> { pub fn new(inner: BoxCloneService<T, U, E>) -> Self { - Self { inner} + Self { inner } } } @@ -111,6 +114,8 @@ impl<T, U, E> Service<T> for MakeSvc<T, U, E> { impl<T, U, E> Clone for MakeSvc<T, U, E> { fn clone(&self) -> Self { - Self { inner: self.inner.clone() } + Self { + inner: self.inner.clone(), + } } -} \ No newline at end of file +} diff --git a/dubbo/src/service/grpc/mod.rs b/dubbo/src/service/grpc/mod.rs index 3350638..7c70105 100644 --- a/dubbo/src/service/grpc/mod.rs +++ b/dubbo/src/service/grpc/mod.rs @@ -1,45 +1,56 @@ -pub mod grpc_protocol; -pub mod grpc_invoker; pub mod grpc_exporter; +pub mod grpc_invoker; +pub mod grpc_protocol; pub mod grpc_server; +use lazy_static::lazy_static; use std::collections::HashMap; use std::sync::RwLock; -use lazy_static::lazy_static; -use grpc_server::DubboGrpcService; -use grpc_invoker::GrpcInvoker; use crate::helloworld::helloworld::greeter_server::Greeter; +use crate::helloworld::helloworld::{HelloReply, HelloRequest}; use crate::utils::boxed_clone::BoxCloneService; -use crate::helloworld::helloworld::{HelloRequest, HelloReply}; +use grpc_invoker::GrpcInvoker; +use grpc_server::DubboGrpcService; -pub type GrpcBoxCloneService = BoxCloneService<http::Request<hyper::Body>, http::Response<tonic::body::BoxBody>, std::convert::Infallible>; +pub type GrpcBoxCloneService = BoxCloneService< + http::Request<hyper::Body>, + http::Response<tonic::body::BoxBody>, + std::convert::Infallible, +>; -pub type DubboGrpcBox = Box<dyn DubboGrpcService<GrpcInvoker>+ Send + Sync + 'static>; +pub type DubboGrpcBox = Box<dyn DubboGrpcService<GrpcInvoker> + Send + Sync + 'static>; lazy_static! { - pub static ref DUBBO_GRPC_SERVICES: RwLock<HashMap<String, Box<dyn DubboGrpcService<GrpcInvoker> + Send + Sync + 'static>>> = RwLock::new(HashMap::new()); - pub static ref GRPC_SERVICES: RwLock<HashMap<String, GrpcBoxCloneService>> = RwLock::new(HashMap::new()); + pub static ref DUBBO_GRPC_SERVICES: RwLock<HashMap<String, Box<dyn DubboGrpcService<GrpcInvoker> + Send + Sync + 'static>>> = + RwLock::new(HashMap::new()); + pub static ref GRPC_SERVICES: RwLock<HashMap<String, GrpcBoxCloneService>> = + RwLock::new(HashMap::new()); } #[tokio::test] async fn test_hello() { - use grpc_server::register_greeter_server; - use crate::service::protocol::Protocol; use crate::common::url::Url; - - let (svc, dubbo_svc) = register_greeter_server(MyGreeter{}); + use crate::service::protocol::Protocol; + use grpc_server::register_greeter_server; + + let (svc, dubbo_svc) = register_greeter_server(MyGreeter {}); let svc_name = dubbo_svc.service_desc().get_service_name(); - DUBBO_GRPC_SERVICES.write().unwrap().insert(svc_name.clone(), dubbo_svc); + DUBBO_GRPC_SERVICES + .write() + .unwrap() + .insert(svc_name.clone(), dubbo_svc); GRPC_SERVICES.write().unwrap().insert(svc_name.clone(), svc); // server start, api: 0.0.0.0:8888/helloworld.Greeter/SayHello let pro = grpc_protocol::GrpcProtocol::new(); - pro.export(Url{url: "[::1]:50051".to_string(), service_key: svc_name.clone()}).await; - + pro.export(Url { + url: "[::1]:50051".to_string(), + service_key: svc_name.clone(), + }) + .await; } - #[derive(Default)] pub struct MyGreeter {} @@ -56,4 +67,4 @@ impl Greeter for MyGreeter { }; Ok(tonic::Response::new(reply)) } -} \ No newline at end of file +} diff --git a/dubbo/src/service/invocation.rs b/dubbo/src/service/invocation.rs index dff46fa..690a345 100644 --- a/dubbo/src/service/invocation.rs +++ b/dubbo/src/service/invocation.rs @@ -5,12 +5,11 @@ pub struct Request<T> { pub metadata: MetadataMap, } - impl<T> Request<T> { pub fn new(message: T) -> Request<T> { Self { message, - metadata: MetadataMap::new() + metadata: MetadataMap::new(), } } @@ -33,13 +32,10 @@ impl<T> Response<T> { } pub fn from_parts(metadata: MetadataMap, message: T) -> Self { - Self { - message, - metadata, - } + Self { message, metadata } } pub fn into_parts(self) -> (MetadataMap, T) { (self.metadata, self.message) } -} \ No newline at end of file +} diff --git a/dubbo/src/service/mod.rs b/dubbo/src/service/mod.rs index 55bcb2f..49d23a4 100644 --- a/dubbo/src/service/mod.rs +++ b/dubbo/src/service/mod.rs @@ -1,4 +1,3 @@ -pub mod protocol; pub mod grpc; pub mod invocation; - +pub mod protocol; diff --git a/dubbo/src/service/protocol.rs b/dubbo/src/service/protocol.rs index 18d2d7b..3f42284 100644 --- a/dubbo/src/service/protocol.rs +++ b/dubbo/src/service/protocol.rs @@ -7,13 +7,12 @@ use async_trait::async_trait; pub trait Protocol { type Invoker; type Exporter; - + fn destroy(&self); async fn export(self, url: Url) -> Self::Exporter; async fn refer(&self, url: Url) -> Self::Invoker; } - pub trait Exporter { type InvokerType: Invoker; @@ -28,4 +27,4 @@ pub trait Invoker { fn is_available(&self) -> bool; fn destroy(&self); fn get_url(&self) -> Url; -} \ No newline at end of file +} diff --git a/dubbo/src/utils/boxed.rs b/dubbo/src/utils/boxed.rs index 63297e9..e820031 100644 --- a/dubbo/src/utils/boxed.rs +++ b/dubbo/src/utils/boxed.rs @@ -20,7 +20,7 @@ use std::{ /// /// See module level documentation for more details. pub struct BoxService<T, U, E> { - inner: Box<dyn Service<T, Response = U, Error = E, Future = BoxFuture<U, E>> + Send+ Sync+>, + inner: Box<dyn Service<T, Response = U, Error = E, Future = BoxFuture<U, E>> + Send + Sync>, } /// A boxed `Future + Send` trait object. diff --git a/dubbo/src/utils/boxed_clone.rs b/dubbo/src/utils/boxed_clone.rs index 0e5e6c3..dde8ec6 100644 --- a/dubbo/src/utils/boxed_clone.rs +++ b/dubbo/src/utils/boxed_clone.rs @@ -1,16 +1,17 @@ -use tower::ServiceExt; use futures_util::future::BoxFuture; use std::{ fmt, task::{Context, Poll}, }; +use tower::ServiceExt; use tower_layer::{layer_fn, LayerFn}; use tower_service::Service; pub struct BoxCloneService<T, U, E>( Box< dyn CloneService<T, Response = U, Error = E, Future = BoxFuture<'static, Result<U, E>>> - + Send+Sync, + + Send + + Sync, >, ); @@ -65,7 +66,8 @@ trait CloneService<R>: Service<R> { &self, ) -> Box< dyn CloneService<R, Response = Self::Response, Error = Self::Error, Future = Self::Future> - + Send + Sync, + + Send + + Sync, >; } @@ -75,8 +77,11 @@ where { fn clone_box( &self, - ) -> Box<dyn CloneService<R, Response = T::Response, Error = T::Error, Future = T::Future> + Send + Sync> - { + ) -> Box< + dyn CloneService<R, Response = T::Response, Error = T::Error, Future = T::Future> + + Send + + Sync, + > { Box::new(self.clone()) } } diff --git a/dubbo/src/utils/mod.rs b/dubbo/src/utils/mod.rs index a3bbaaa..bd5e148 100644 --- a/dubbo/src/utils/mod.rs +++ b/dubbo/src/utils/mod.rs @@ -1,2 +1,2 @@ pub mod boxed; -pub mod boxed_clone; \ No newline at end of file +pub mod boxed_clone;
