use crate::buildservice::BuildService; use std::ops::Deref; use tonic::async_trait; use super::{Build, BuildRequest}; /// Implements the gRPC server trait ([crate::proto::build_service_server::BuildService] /// for anything implementing [BuildService]. pub struct GRPCBuildServiceWrapper { inner: BUILD, } impl GRPCBuildServiceWrapper { pub fn new(build_service: BUILD) -> Self { Self { inner: build_service, } } } #[async_trait] impl crate::proto::build_service_server::BuildService for GRPCBuildServiceWrapper where BUILD: Deref + Send + Sync + 'static, { async fn do_build( &self, request: tonic::Request, ) -> Result, tonic::Status> { match self.inner.do_build(request.into_inner()).await { Ok(resp) => Ok(tonic::Response::new(resp)), Err(e) => Err(tonic::Status::internal(e.to_string())), } } }