Add grpc rust codegen + stubs, add rppal compile feature

for raspberry pi compilation.

This is because rppal won't compile on mac, so we
only want to bring in the dependency when actually compiling
for the raspberry pi, and so will manually need to enable the
dependency.
This commit is contained in:
Piv
2022-08-06 20:34:00 +09:30
parent 26647017c3
commit d876fcbb2e
7 changed files with 395 additions and 32 deletions

52
car-rs/src/grpcserver.rs Normal file
View File

@@ -0,0 +1,52 @@
pub mod motor_control_service {
tonic::include_proto!("motor_control");
}
use motor_control_service::car_control_server::CarControl;
use tonic::{Request, Response, Status, Streaming};
use self::motor_control_service::{
RecordingReqeust, RecordingResponse, SaveRequest, SaveResponse, SteeringRequest,
SteeringResponse, ThrottleRequest, ThrottleResponse, Vehicle2DRequest, Vehicle2DResponse,
};
#[derive(Debug)]
struct MotorControlService {}
#[tonic::async_trait]
impl CarControl for MotorControlService {
async fn set_throttle(
&self,
_request: Request<ThrottleRequest>,
) -> Result<Response<ThrottleResponse>, Status> {
unimplemented!()
}
async fn set_steering(
&self,
_request: Request<SteeringRequest>,
) -> Result<Response<SteeringResponse>, Status> {
unimplemented!()
}
async fn stream_vehicle_2d(
&self,
_request: Request<Streaming<Vehicle2DRequest>>,
) -> Result<Response<Vehicle2DResponse>, Status> {
unimplemented!()
}
async fn record(
&self,
_request: Request<RecordingReqeust>,
) -> Result<Response<RecordingResponse>, Status> {
unimplemented!()
}
async fn save_recorded_data(
&self,
_request: Request<SaveRequest>,
) -> Result<Response<SaveResponse>, Status> {
unimplemented!()
}
}