Files
voidpin/crates/voidpin/src/grpc_server.rs
kjuulh 881094e484
All checks were successful
continuous-integration/drone/push Build is passing
feat: add basic remote copu
2025-01-14 08:16:50 +01:00

31 lines
731 B
Rust

use crate::{copy::LocalCopierState, state::State};
#[derive(Clone)]
pub struct GrpcServer {
state: State,
}
impl GrpcServer {
pub fn new(state: State) -> Self {
Self { state }
}
}
#[async_trait::async_trait]
impl crate::grpc::void_pin_server::VoidPin for GrpcServer {
async fn copy(
&self,
req: tonic::Request<crate::grpc::CopyRequest>,
) -> Result<tonic::Response<crate::grpc::CopyResponse>, tonic::Status> {
let req = req.into_inner();
self.state
.local_copier()
.copy(&req.content)
.await
.map_err(|e| tonic::Status::internal(e.to_string()))?;
Ok(tonic::Response::new(crate::grpc::CopyResponse {}))
}
}