1use futures::{Sink, Stream};
2use hopr_protocol_app::prelude::{ApplicationDataIn, ApplicationDataOut};
3use hopr_transport_session::DestinationRouting;
4
5pub struct HoprSocket<T, U> {
13 rx: T,
14 tx: U,
15}
16
17impl<T, U> From<(T, U)> for HoprSocket<T, U>
18where
19 T: Stream<Item = ApplicationDataIn> + Send + 'static,
20 U: Sink<(DestinationRouting, ApplicationDataOut)> + Send + Clone + 'static,
21{
22 fn from(value: (T, U)) -> Self {
23 Self {
24 rx: value.0,
25 tx: value.1,
26 }
27 }
28}
29
30impl<T, U> HoprSocket<T, U>
31where
32 T: Stream<Item = ApplicationDataIn> + Send + 'static,
33 U: Sink<(DestinationRouting, ApplicationDataOut)> + Send + Clone + 'static,
34{
35 pub fn reader(self) -> T {
36 self.rx
37 }
38
39 pub fn writer(&self) -> U {
40 self.tx.clone()
41 }
42}