diff --git a/nexosim/src/grpc/api/simulation.proto b/nexosim/src/grpc/api/simulation.proto index e26759e..b40a998 100644 --- a/nexosim/src/grpc/api/simulation.proto +++ b/nexosim/src/grpc/api/simulation.proto @@ -1,7 +1,7 @@ // The main simulation protocol. syntax = "proto3"; -package simulation; +package simulation.v1; import "google/protobuf/duration.proto"; import "google/protobuf/timestamp.proto"; diff --git a/nexosim/src/grpc/codegen.rs b/nexosim/src/grpc/codegen.rs index c98125f..1605485 100644 --- a/nexosim/src/grpc/codegen.rs +++ b/nexosim/src/grpc/codegen.rs @@ -3,4 +3,5 @@ #![allow(missing_docs)] #[rustfmt::skip] +#[path = "codegen/simulation.v1.rs"] pub(crate) mod simulation; diff --git a/nexosim/src/grpc/codegen/simulation.rs b/nexosim/src/grpc/codegen/simulation.v1.rs similarity index 85% rename from nexosim/src/grpc/codegen/simulation.rs rename to nexosim/src/grpc/codegen/simulation.v1.rs index cf75b70..8346678 100644 --- a/nexosim/src/grpc/codegen/simulation.rs +++ b/nexosim/src/grpc/codegen/simulation.v1.rs @@ -299,10 +299,7 @@ pub mod close_sink_reply { #[derive(Clone, PartialEq, ::prost::Message)] pub struct AnyRequest { /// Expects exactly 1 variant. - #[prost( - oneof = "any_request::Request", - tags = "1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11" - )] + #[prost(oneof = "any_request::Request", tags = "1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11")] pub request: ::core::option::Option, } /// Nested message and enum types in `AnyRequest`. @@ -418,7 +415,7 @@ pub mod simulation_server { dead_code, missing_docs, clippy::wildcard_imports, - clippy::let_unit_value + clippy::let_unit_value, )] use tonic::codegen::*; /// Generated trait containing gRPC methods that should be implemented for use with SimulationServer. @@ -443,19 +440,31 @@ pub mod simulation_server { async fn schedule_event( &self, request: tonic::Request, - ) -> std::result::Result, tonic::Status>; + ) -> std::result::Result< + tonic::Response, + tonic::Status, + >; async fn cancel_event( &self, request: tonic::Request, - ) -> std::result::Result, tonic::Status>; + ) -> std::result::Result< + tonic::Response, + tonic::Status, + >; async fn process_event( &self, request: tonic::Request, - ) -> std::result::Result, tonic::Status>; + ) -> std::result::Result< + tonic::Response, + tonic::Status, + >; async fn process_query( &self, request: tonic::Request, - ) -> std::result::Result, tonic::Status>; + ) -> std::result::Result< + tonic::Response, + tonic::Status, + >; async fn read_events( &self, request: tonic::Request, @@ -490,7 +499,10 @@ pub mod simulation_server { max_encoding_message_size: None, } } - pub fn with_interceptor(inner: T, interceptor: F) -> InterceptedService + pub fn with_interceptor( + inner: T, + interceptor: F, + ) -> InterceptedService where F: tonic::service::Interceptor, { @@ -542,18 +554,24 @@ pub mod simulation_server { } fn call(&mut self, req: http::Request) -> Self::Future { match req.uri().path() { - "/simulation.Simulation/Init" => { + "/simulation.v1.Simulation/Init" => { #[allow(non_camel_case_types)] struct InitSvc(pub Arc); - impl tonic::server::UnaryService for InitSvc { + impl tonic::server::UnaryService + for InitSvc { type Response = super::InitReply; - type Future = BoxFuture, tonic::Status>; + type Future = BoxFuture< + tonic::Response, + tonic::Status, + >; fn call( &mut self, request: tonic::Request, ) -> Self::Future { let inner = Arc::clone(&self.0); - let fut = async move { ::init(&inner, request).await }; + let fut = async move { + ::init(&inner, request).await + }; Box::pin(fut) } } @@ -579,18 +597,24 @@ pub mod simulation_server { }; Box::pin(fut) } - "/simulation.Simulation/Time" => { + "/simulation.v1.Simulation/Time" => { #[allow(non_camel_case_types)] struct TimeSvc(pub Arc); - impl tonic::server::UnaryService for TimeSvc { + impl tonic::server::UnaryService + for TimeSvc { type Response = super::TimeReply; - type Future = BoxFuture, tonic::Status>; + type Future = BoxFuture< + tonic::Response, + tonic::Status, + >; fn call( &mut self, request: tonic::Request, ) -> Self::Future { let inner = Arc::clone(&self.0); - let fut = async move { ::time(&inner, request).await }; + let fut = async move { + ::time(&inner, request).await + }; Box::pin(fut) } } @@ -616,18 +640,24 @@ pub mod simulation_server { }; Box::pin(fut) } - "/simulation.Simulation/Step" => { + "/simulation.v1.Simulation/Step" => { #[allow(non_camel_case_types)] struct StepSvc(pub Arc); - impl tonic::server::UnaryService for StepSvc { + impl tonic::server::UnaryService + for StepSvc { type Response = super::StepReply; - type Future = BoxFuture, tonic::Status>; + type Future = BoxFuture< + tonic::Response, + tonic::Status, + >; fn call( &mut self, request: tonic::Request, ) -> Self::Future { let inner = Arc::clone(&self.0); - let fut = async move { ::step(&inner, request).await }; + let fut = async move { + ::step(&inner, request).await + }; Box::pin(fut) } } @@ -653,19 +683,26 @@ pub mod simulation_server { }; Box::pin(fut) } - "/simulation.Simulation/StepUntil" => { + "/simulation.v1.Simulation/StepUntil" => { #[allow(non_camel_case_types)] struct StepUntilSvc(pub Arc); - impl tonic::server::UnaryService for StepUntilSvc { + impl< + T: Simulation, + > tonic::server::UnaryService + for StepUntilSvc { type Response = super::StepUntilReply; - type Future = BoxFuture, tonic::Status>; + type Future = BoxFuture< + tonic::Response, + tonic::Status, + >; fn call( &mut self, request: tonic::Request, ) -> Self::Future { let inner = Arc::clone(&self.0); - let fut = - async move { ::step_until(&inner, request).await }; + let fut = async move { + ::step_until(&inner, request).await + }; Box::pin(fut) } } @@ -691,14 +728,18 @@ pub mod simulation_server { }; Box::pin(fut) } - "/simulation.Simulation/ScheduleEvent" => { + "/simulation.v1.Simulation/ScheduleEvent" => { #[allow(non_camel_case_types)] struct ScheduleEventSvc(pub Arc); - impl tonic::server::UnaryService - for ScheduleEventSvc - { + impl< + T: Simulation, + > tonic::server::UnaryService + for ScheduleEventSvc { type Response = super::ScheduleEventReply; - type Future = BoxFuture, tonic::Status>; + type Future = BoxFuture< + tonic::Response, + tonic::Status, + >; fn call( &mut self, request: tonic::Request, @@ -732,12 +773,18 @@ pub mod simulation_server { }; Box::pin(fut) } - "/simulation.Simulation/CancelEvent" => { + "/simulation.v1.Simulation/CancelEvent" => { #[allow(non_camel_case_types)] struct CancelEventSvc(pub Arc); - impl tonic::server::UnaryService for CancelEventSvc { + impl< + T: Simulation, + > tonic::server::UnaryService + for CancelEventSvc { type Response = super::CancelEventReply; - type Future = BoxFuture, tonic::Status>; + type Future = BoxFuture< + tonic::Response, + tonic::Status, + >; fn call( &mut self, request: tonic::Request, @@ -771,12 +818,18 @@ pub mod simulation_server { }; Box::pin(fut) } - "/simulation.Simulation/ProcessEvent" => { + "/simulation.v1.Simulation/ProcessEvent" => { #[allow(non_camel_case_types)] struct ProcessEventSvc(pub Arc); - impl tonic::server::UnaryService for ProcessEventSvc { + impl< + T: Simulation, + > tonic::server::UnaryService + for ProcessEventSvc { type Response = super::ProcessEventReply; - type Future = BoxFuture, tonic::Status>; + type Future = BoxFuture< + tonic::Response, + tonic::Status, + >; fn call( &mut self, request: tonic::Request, @@ -810,12 +863,18 @@ pub mod simulation_server { }; Box::pin(fut) } - "/simulation.Simulation/ProcessQuery" => { + "/simulation.v1.Simulation/ProcessQuery" => { #[allow(non_camel_case_types)] struct ProcessQuerySvc(pub Arc); - impl tonic::server::UnaryService for ProcessQuerySvc { + impl< + T: Simulation, + > tonic::server::UnaryService + for ProcessQuerySvc { type Response = super::ProcessQueryReply; - type Future = BoxFuture, tonic::Status>; + type Future = BoxFuture< + tonic::Response, + tonic::Status, + >; fn call( &mut self, request: tonic::Request, @@ -849,12 +908,18 @@ pub mod simulation_server { }; Box::pin(fut) } - "/simulation.Simulation/ReadEvents" => { + "/simulation.v1.Simulation/ReadEvents" => { #[allow(non_camel_case_types)] struct ReadEventsSvc(pub Arc); - impl tonic::server::UnaryService for ReadEventsSvc { + impl< + T: Simulation, + > tonic::server::UnaryService + for ReadEventsSvc { type Response = super::ReadEventsReply; - type Future = BoxFuture, tonic::Status>; + type Future = BoxFuture< + tonic::Response, + tonic::Status, + >; fn call( &mut self, request: tonic::Request, @@ -888,19 +953,26 @@ pub mod simulation_server { }; Box::pin(fut) } - "/simulation.Simulation/OpenSink" => { + "/simulation.v1.Simulation/OpenSink" => { #[allow(non_camel_case_types)] struct OpenSinkSvc(pub Arc); - impl tonic::server::UnaryService for OpenSinkSvc { + impl< + T: Simulation, + > tonic::server::UnaryService + for OpenSinkSvc { type Response = super::OpenSinkReply; - type Future = BoxFuture, tonic::Status>; + type Future = BoxFuture< + tonic::Response, + tonic::Status, + >; fn call( &mut self, request: tonic::Request, ) -> Self::Future { let inner = Arc::clone(&self.0); - let fut = - async move { ::open_sink(&inner, request).await }; + let fut = async move { + ::open_sink(&inner, request).await + }; Box::pin(fut) } } @@ -926,19 +998,26 @@ pub mod simulation_server { }; Box::pin(fut) } - "/simulation.Simulation/CloseSink" => { + "/simulation.v1.Simulation/CloseSink" => { #[allow(non_camel_case_types)] struct CloseSinkSvc(pub Arc); - impl tonic::server::UnaryService for CloseSinkSvc { + impl< + T: Simulation, + > tonic::server::UnaryService + for CloseSinkSvc { type Response = super::CloseSinkReply; - type Future = BoxFuture, tonic::Status>; + type Future = BoxFuture< + tonic::Response, + tonic::Status, + >; fn call( &mut self, request: tonic::Request, ) -> Self::Future { let inner = Arc::clone(&self.0); - let fut = - async move { ::close_sink(&inner, request).await }; + let fut = async move { + ::close_sink(&inner, request).await + }; Box::pin(fut) } } @@ -964,19 +1043,23 @@ pub mod simulation_server { }; Box::pin(fut) } - _ => Box::pin(async move { - let mut response = http::Response::new(empty_body()); - let headers = response.headers_mut(); - headers.insert( - tonic::Status::GRPC_STATUS, - (tonic::Code::Unimplemented as i32).into(), - ); - headers.insert( - http::header::CONTENT_TYPE, - tonic::metadata::GRPC_CONTENT_TYPE, - ); - Ok(response) - }), + _ => { + Box::pin(async move { + let mut response = http::Response::new(empty_body()); + let headers = response.headers_mut(); + headers + .insert( + tonic::Status::GRPC_STATUS, + (tonic::Code::Unimplemented as i32).into(), + ); + headers + .insert( + http::header::CONTENT_TYPE, + tonic::metadata::GRPC_CONTENT_TYPE, + ); + Ok(response) + }) + } } } } @@ -993,7 +1076,7 @@ pub mod simulation_server { } } /// Generated gRPC service name - pub const SERVICE_NAME: &str = "simulation.Simulation"; + pub const SERVICE_NAME: &str = "simulation.v1.Simulation"; impl tonic::server::NamedService for SimulationServer { const NAME: &'static str = SERVICE_NAME; }