use crate::{api::DistantMsg, data::DistantResponseData}; use distant_net::server::Reply; use std::{future::Future, io, pin::Pin}; /// Wrapper around a reply that can be batch or single, converting /// a single data into the wrapped type pub struct DistantSingleReply(Box>>); impl From>>> for DistantSingleReply { fn from(reply: Box>>) -> Self { Self(reply) } } impl Reply for DistantSingleReply { type Data = DistantResponseData; fn send(&self, data: Self::Data) -> Pin> + Send + '_>> { self.0.send(DistantMsg::Single(data)) } fn blocking_send(&self, data: Self::Data) -> io::Result<()> { self.0.blocking_send(DistantMsg::Single(data)) } fn clone_reply(&self) -> Box> { Box::new(Self(self.0.clone_reply())) } }