Mathias Gottschlag 5 лет назад
Родитель
Сommit
509bf425be
1 измененных файлов: 3 добавлений и 21 удалений
  1. 3
    21
      src/network/client.rs

+ 3
- 21
src/network/client.rs Просмотреть файл

@@ -41,12 +41,7 @@ where
41 41
         task.run().await;
42 42
     });
43 43
 
44
-    (
45
-        RPCInterface { cmd_send },
46
-        ServerEventStream {
47
-            packets: Box::pin(event_receive),
48
-        },
49
-    )
44
+    (RPCInterface { cmd_send }, Box::pin(event_receive))
50 45
 }
51 46
 
52 47
 enum ClientTaskCommand<PacketType, ErrorType> {
@@ -306,21 +301,8 @@ impl<PacketType, ErrorType> Future for RPC<PacketType, ErrorType> {
306 301
     }
307 302
 }
308 303
 
309
-// TODO: Do we even need this type?
310
-pub struct ServerEventStream<PacketType> {
311
-    packets: Pin<Box<mpsc::Receiver<PacketType>>>,
312
-}
313
-
314
-impl<PacketType> Stream for ServerEventStream<PacketType> {
315
-    type Item = PacketType;
316
-
317
-    fn poll_next(self: Pin<&mut Self>, cx: &mut Context) -> Poll<Option<Self::Item>> {
318
-        // Safe, as we will not move self_.
319
-        let self_ = unsafe { self.get_unchecked_mut() };
320
-
321
-        Pin::as_mut(&mut self_.packets).poll_next(cx)
322
-    }
323
-}
304
+/// Stream of asynchronous packets received from the server.
305
+type ServerEventStream<PacketType> = Pin<Box<mpsc::Receiver<PacketType>>>;
324 306
 
325 307
 #[derive(Debug, PartialEq)]
326 308
 pub enum RPCError<StreamError> {

Загрузка…
Отмена
Сохранить