diff --git a/crates/papyrus_network/src/network_manager/mod.rs b/crates/papyrus_network/src/network_manager/mod.rs index d754195e63..b058d9c339 100644 --- a/crates/papyrus_network/src/network_manager/mod.rs +++ b/crates/papyrus_network/src/network_manager/mod.rs @@ -613,7 +613,7 @@ pub fn dummy_report_sender() -> ReportSender { Box::new(|| {}) } -pub type GenericSender = Box>; +pub type GenericSender = Box + Unpin>; // Box implements Stream only if S: Stream + Unpin pub type GenericReceiver = Box + Unpin>; @@ -631,7 +631,14 @@ pub struct SqmrServerPayload> { #[allow(dead_code)] struct SqmrClientPayloadForNetwork { pub query: Bytes, - pub report_receiver: BoxFuture<'static, SessionId>, + pub report_receiver: oneshot::Receiver<()>, + pub responses_sender: GenericSender, +} + +#[allow(dead_code)] +struct SqmrServerPayloadForNetwork { + pub query: Bytes, + pub report_sender: oneshot::Sender<()>, pub responses_sender: GenericSender, } @@ -645,11 +652,18 @@ pub type SqmrServerReceiver = GenericReceiver; -impl> From> - for SqmrClientPayloadForNetwork +impl From> for SqmrClientPayloadForNetwork +where + Bytes: From, + Response: TryFrom + 'static, + >::Error: 'static, { - fn from(_query: SqmrClientPayload) -> Self { - unimplemented!() + fn from(payload: SqmrClientPayload) -> Self { + let SqmrClientPayload { query, report_receiver, responses_sender } = payload; + let query = Bytes::from(query); + let responses_sender = + Box::new(responses_sender.with(|response| ready(Ok(Response::try_from(response))))); + Self { query, report_receiver, responses_sender } } } @@ -661,13 +675,6 @@ impl> From } } -#[allow(dead_code)] -struct SqmrServerPayloadForNetwork { - pub query: Bytes, - pub report_sender: oneshot::Sender<()>, - pub responses_sender: GenericSender, -} - // TODO(shahak): Create a custom struct if Box dyn becomes an overhead. // TODO(eitan): Change type to oneshot::Sender<()> pub type ReportSender = Box;