diff --git a/out/helloworld.rs b/out/helloworld.rs deleted file mode 100644 index 7beae83..0000000 --- a/out/helloworld.rs +++ /dev/null @@ -1,128 +0,0 @@ -/// The request message containing the user's name. -#[derive(Clone, PartialEq, ::prost::Message)] -pub struct HelloRequest { - #[prost(string, tag = "1")] - pub name: std::string::String, -} -/// The response message containing the greetings -#[derive(Clone, PartialEq, ::prost::Message)] -pub struct HelloReply { - #[prost(string, tag = "1")] - pub message: std::string::String, -} -use tonic::_codegen::*; -#[async_trait] -pub trait Greeter: Send + Sync + 'static { - async fn say_hello( - &self, - request: tonic::Request, - ) -> Result, tonic::Status>; -} -#[derive(Clone)] -pub struct GreeterServer { - inner: std::sync::Arc, -} -pub struct GreeterServerSvc { - inner: std::sync::Arc, -} -impl GreeterServer { - pub fn new(inner: T) -> Self { - let inner = std::sync::Arc::new(inner); - Self { inner } - } -} -impl GreeterServerSvc { - pub fn new(inner: std::sync::Arc) -> Self { - Self { inner } - } -} -impl Service for GreeterServer { - type Response = GreeterServerSvc; - type Error = tonic::error::Never; - type Future = Ready>; - fn poll_ready(&mut self, _cx: &mut Context<'_>) -> Poll> { - Poll::Ready(Ok(())) - } - fn call(&mut self, _: R) -> Self::Future { - ok(GreeterServerSvc::new(self.inner.clone())) - } -} -impl Service> for GreeterServerSvc { - type Response = http::Response; - type Error = tonic::error::Never; - type Future = BoxFuture; - fn poll_ready(&mut self, _cx: &mut Context<'_>) -> Poll> { - Poll::Ready(Ok(())) - } - fn call(&mut self, req: http::Request) -> Self::Future { - let inner = self.inner.clone(); - match req.uri().path() { - "/helloworld.Greeter/SayHello" => { - struct SayHello(pub std::sync::Arc); - impl tonic::server::UnaryService for SayHello { - type Response = self::HelloReply; - type Future = BoxFuture, tonic::Status>; - fn call( - &mut self, - request: tonic::Request, - ) -> Self::Future { - let inner = self.0.clone(); - let fut = async move { inner.say_hello(request).await }; - Box::pin(fut) - } - } - let inner = self.inner.clone(); - let fut = async move { - let method = SayHello(inner); - let codec = tonic::codec::ProstCodec::new(); - let mut grpc = tonic::server::Grpc::new(codec); - let res = grpc.unary(method, req).await; - Ok(res) - }; - Box::pin(fut) - } - _ => unimplemented!("use grpc unimplemented"), - } - } -} -use tonic::_codegen::*; -pub struct GreeterClient { - inner: tonic::client::Grpc, -} -impl GreeterClient -where - T: tonic::client::GrpcService, - T::ResponseBody: tonic::body::Body + tonic::_codegen::HttpBody + Send + 'static, - T::Error: Into, - ::Error: Into + Send, - ::Data: Into + Send, -{ - pub fn new(inner: T) -> Self { - let inner = tonic::client::Grpc::new(inner); - Self { inner } - } - pub async fn ready(&mut self) -> Result<(), tonic::Status> { - self.inner.ready().await.map_err(|e| { - tonic::Status::new( - tonic::Code::Unknown, - format!("Service was not ready: {}", e.into()), - ) - }) - } - pub async fn say_hello( - &mut self, - request: tonic::Request, - ) -> Result, tonic::Status> { - self.ready().await?; - let codec = tonic::codec::ProstCodec::new(); - let path = http::uri::PathAndQuery::from_static("/helloworld.Greeter/SayHello"); - self.inner.unary(request, path, codec).await - } -} -impl Clone for GreeterClient { - fn clone(&self) -> Self { - Self { - inner: self.inner.clone(), - } - } -} diff --git a/out/routeguide.rs b/out/routeguide.rs deleted file mode 100644 index e7f150a..0000000 --- a/out/routeguide.rs +++ /dev/null @@ -1,303 +0,0 @@ -/// Points are represented as latitude-longitude pairs in the E7 representation -/// (degrees multiplied by 10**7 and rounded to the nearest integer). -/// Latitudes should be in the range +/- 90 degrees and longitude should be in -/// the range +/- 180 degrees (inclusive). -#[derive(Clone, PartialEq, ::prost::Message)] -pub struct Point { - #[prost(int32, tag = "1")] - pub latitude: i32, - #[prost(int32, tag = "2")] - pub longitude: i32, -} -/// A latitude-longitude rectangle, represented as two diagonally opposite -/// points "lo" and "hi". -#[derive(Clone, PartialEq, ::prost::Message)] -pub struct Rectangle { - /// One corner of the rectangle. - #[prost(message, optional, tag = "1")] - pub lo: ::std::option::Option, - /// The other corner of the rectangle. - #[prost(message, optional, tag = "2")] - pub hi: ::std::option::Option, -} -/// A feature names something at a given point. -/// -/// If a feature could not be named, the name is empty. -#[derive(Clone, PartialEq, ::prost::Message)] -pub struct Feature { - /// The name of the feature. - #[prost(string, tag = "1")] - pub name: std::string::String, - /// The point where the feature is detected. - #[prost(message, optional, tag = "2")] - pub location: ::std::option::Option, -} -/// A RouteNote is a message sent while at a given point. -#[derive(Clone, PartialEq, ::prost::Message)] -pub struct RouteNote { - /// The location from which the message is sent. - #[prost(message, optional, tag = "1")] - pub location: ::std::option::Option, - /// The message to be sent. - #[prost(string, tag = "2")] - pub message: std::string::String, -} -/// A RouteSummary is received in response to a RecordRoute rpc. -/// -/// It contains the number of individual points received, the number of -/// detected features, and the total distance covered as the cumulative sum of -/// the distance between each point. -#[derive(Clone, PartialEq, ::prost::Message)] -pub struct RouteSummary { - /// The number of points received. - #[prost(int32, tag = "1")] - pub point_count: i32, - /// The number of known features passed while traversing the route. - #[prost(int32, tag = "2")] - pub feature_count: i32, - /// The distance covered in metres. - #[prost(int32, tag = "3")] - pub distance: i32, - /// The duration of the traversal in seconds. - #[prost(int32, tag = "4")] - pub elapsed_time: i32, -} -use tonic::_codegen::*; -#[async_trait] -pub trait RouteGuide: Send + Sync + 'static { - async fn get_feature( - &self, - request: tonic::Request, - ) -> Result, tonic::Status>; - type ListFeaturesStream: Stream> - + Unpin - + Send - + 'static; - async fn list_features( - &self, - request: tonic::Request, - ) -> Result, tonic::Status>; - async fn record_route( - &self, - request: tonic::Request>, - ) -> Result, tonic::Status>; - type RouteChatStream: Stream> - + Unpin - + Send - + 'static; - async fn route_chat( - &self, - request: tonic::Request>, - ) -> Result, tonic::Status>; -} -#[derive(Clone)] -pub struct RouteGuideServer { - inner: std::sync::Arc, -} -pub struct RouteGuideServerSvc { - inner: std::sync::Arc, -} -impl RouteGuideServer { - pub fn new(inner: T) -> Self { - let inner = std::sync::Arc::new(inner); - Self { inner } - } -} -impl RouteGuideServerSvc { - pub fn new(inner: std::sync::Arc) -> Self { - Self { inner } - } -} -impl Service for RouteGuideServer { - type Response = RouteGuideServerSvc; - type Error = tonic::error::Never; - type Future = Ready>; - fn poll_ready(&mut self, _cx: &mut Context<'_>) -> Poll> { - Poll::Ready(Ok(())) - } - fn call(&mut self, _: R) -> Self::Future { - ok(RouteGuideServerSvc::new(self.inner.clone())) - } -} -impl Service> for RouteGuideServerSvc { - type Response = http::Response; - type Error = tonic::error::Never; - type Future = BoxFuture; - fn poll_ready(&mut self, _cx: &mut Context<'_>) -> Poll> { - Poll::Ready(Ok(())) - } - fn call(&mut self, req: http::Request) -> Self::Future { - let inner = self.inner.clone(); - match req.uri().path() { - "/routeguide.RouteGuide/GetFeature" => { - struct GetFeature(pub std::sync::Arc); - impl tonic::server::UnaryService for GetFeature { - type Response = self::Feature; - type Future = BoxFuture, tonic::Status>; - fn call(&mut self, request: tonic::Request) -> Self::Future { - let inner = self.0.clone(); - let fut = async move { inner.get_feature(request).await }; - Box::pin(fut) - } - } - let inner = self.inner.clone(); - let fut = async move { - let method = GetFeature(inner); - let codec = tonic::codec::ProstCodec::new(); - let mut grpc = tonic::server::Grpc::new(codec); - let res = grpc.unary(method, req).await; - Ok(res) - }; - Box::pin(fut) - } - "/routeguide.RouteGuide/ListFeatures" => { - struct ListFeatures(pub std::sync::Arc); - impl tonic::server::ServerStreamingService for ListFeatures { - type Response = self::Feature; - type ResponseStream = T::ListFeaturesStream; - type Future = BoxFuture, tonic::Status>; - fn call(&mut self, request: tonic::Request) -> Self::Future { - let inner = self.0.clone(); - let fut = async move { inner.list_features(request).await }; - Box::pin(fut) - } - } - let inner = self.inner.clone(); - let fut = async move { - let method = ListFeatures(inner); - let codec = tonic::codec::ProstCodec::new(); - let mut grpc = tonic::server::Grpc::new(codec); - let res = grpc.server_streaming(method, req).await; - Ok(res) - }; - Box::pin(fut) - } - "/routeguide.RouteGuide/RecordRoute" => { - struct RecordRoute(pub std::sync::Arc); - impl tonic::server::ClientStreamingService for RecordRoute { - type Response = self::RouteSummary; - type Future = BoxFuture, tonic::Status>; - fn call( - &mut self, - request: tonic::Request>, - ) -> Self::Future { - let inner = self.0.clone(); - let fut = async move { inner.record_route(request).await }; - Box::pin(fut) - } - } - let inner = self.inner.clone(); - let fut = async move { - let method = RecordRoute(inner); - let codec = tonic::codec::ProstCodec::new(); - let mut grpc = tonic::server::Grpc::new(codec); - let res = grpc.client_streaming(method, req).await; - Ok(res) - }; - Box::pin(fut) - } - "/routeguide.RouteGuide/RouteChat" => { - struct RouteChat(pub std::sync::Arc); - impl tonic::server::StreamingService for RouteChat { - type Response = self::RouteNote; - type ResponseStream = T::RouteChatStream; - type Future = BoxFuture, tonic::Status>; - fn call( - &mut self, - request: tonic::Request>, - ) -> Self::Future { - let inner = self.0.clone(); - let fut = async move { inner.route_chat(request).await }; - Box::pin(fut) - } - } - let inner = self.inner.clone(); - let fut = async move { - let method = RouteChat(inner); - let codec = tonic::codec::ProstCodec::new(); - let mut grpc = tonic::server::Grpc::new(codec); - let res = grpc.streaming(method, req).await; - Ok(res) - }; - Box::pin(fut) - } - _ => unimplemented!("use grpc unimplemented"), - } - } -} -use tonic::_codegen::*; -pub struct RouteGuideClient { - inner: tonic::client::Grpc, -} -impl RouteGuideClient -where - T: tonic::client::GrpcService, - T::ResponseBody: tonic::body::Body + tonic::_codegen::HttpBody + Send + 'static, - T::Error: Into, - ::Error: Into + Send, - ::Data: Into + Send, -{ - pub fn new(inner: T) -> Self { - let inner = tonic::client::Grpc::new(inner); - Self { inner } - } - pub async fn ready(&mut self) -> Result<(), tonic::Status> { - self.inner.ready().await.map_err(|e| { - tonic::Status::new( - tonic::Code::Unknown, - format!("Service was not ready: {}", e.into()), - ) - }) - } - pub async fn get_feature( - &mut self, - request: tonic::Request, - ) -> Result, tonic::Status> { - self.ready().await?; - let codec = tonic::codec::ProstCodec::new(); - let path = http::uri::PathAndQuery::from_static("/routeguide.RouteGuide/GetFeature"); - self.inner.unary(request, path, codec).await - } - pub async fn list_features( - &mut self, - request: tonic::Request, - ) -> Result>, tonic::Status> { - self.ready().await?; - let codec = tonic::codec::ProstCodec::new(); - let path = http::uri::PathAndQuery::from_static("/routeguide.RouteGuide/ListFeatures"); - self.inner.server_streaming(request, path, codec).await - } - pub async fn record_route( - &mut self, - request: tonic::Request, - ) -> Result, tonic::Status> - where - S: tonic::_codegen::Stream> + Send + 'static, - { - self.ready().await?; - let codec = tonic::codec::ProstCodec::new(); - let path = http::uri::PathAndQuery::from_static("/routeguide.RouteGuide/RecordRoute"); - let request = request.map(|s| Box::pin(s)); - self.inner.client_streaming(request, path, codec).await - } - pub async fn route_chat( - &mut self, - request: tonic::Request, - ) -> Result>, tonic::Status> - where - S: tonic::_codegen::Stream> + Send + 'static, - { - self.ready().await?; - let codec = tonic::codec::ProstCodec::new(); - let path = http::uri::PathAndQuery::from_static("/routeguide.RouteGuide/RouteChat"); - let request = request.map(|s| Box::pin(s)); - self.inner.streaming(request, path, codec).await - } -} -impl Clone for RouteGuideClient { - fn clone(&self) -> Self { - Self { - inner: self.inner.clone(), - } - } -}