| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990 |
- use futures::Future;
- use futures::task::{Context, Poll};
- use core::pin::Pin;
- use tokio::stream::Stream;
- use async_tungstenite::{tokio::connect_async, tungstenite::Message, WebSocketStream};
- use url::Url;
-
- use super::packet_connection::IncomingPacket;
-
- use std::time::Duration;
-
- pub trait RPCInterface {
- type PacketType;
- type NetworkError;
- type Call: RPC<Output = Result<IncomingPacket<Self::PacketType>, Self::NetworkError>>;
-
- fn call(call: &Self::PacketType) -> Self::Call;
- }
-
- pub trait RPC: Future {
- fn with_timeout(self, timeout: Duration) -> Self;
- }
-
- pub trait ServerEventStream<PacketType>: Stream<Item = PacketType> {}
-
- pub struct WSRPCInterface<PacketType, Stream> {
- // TODO
- _unused: PacketType,
- stream: WebSocketStream<Stream>,
- }
-
- impl<P, S> WSRPCInterface<P, S> {
- fn create<P2, S2>(ws_stream: WebSocketStream<S2>) -> (Self, WSServerEventStream<P2>) {
- // TODO
- panic!("Not yet implemented.");
- }
- }
-
- impl<P, S> RPCInterface for WSRPCInterface<P, S> {
- type PacketType = P;
- type NetworkError = String; // TODO
-
- type Call = WSRPC<Self::PacketType>;
-
- fn call(call: &Self::PacketType) -> Self::Call {
- // TODO
- panic!("Not yet implemented.");
- }
- }
-
- pub struct WSRPC<PacketType> {
- // TODO
- _unused: PacketType,
- }
-
- impl<P> Future for WSRPC<P> {
- type Output = Result<IncomingPacket<P>, String>;
-
- fn poll(self: Pin<&mut Self>, cx: &mut Context) -> Poll<Self::Output> {
- // TODO
- panic!("Not yet implemented.");
- }
- }
-
- impl<P> RPC for WSRPC<P> {
- fn with_timeout(self, timeout: Duration) -> Self {
- // TODO
- panic!("Not yet implemented.");
- }
- }
-
- struct WSServerEventStream<PacketType> {
- _unused: PacketType,
- }
-
- impl<P> Stream for WSServerEventStream<P> {
- type Item = P;
-
- fn poll_next(self: Pin<&mut Self>, cx: &mut Context) -> Poll<Option<Self::Item>> {
- // TODO
- panic!("Not yet implemented.");
- }
- }
-
-
- pub async fn low_level_integration_test_client(address: String) {
- let url = Url::parse(&address).unwrap();
- let (mut ws_stream, _) = connect_async(url).await.unwrap();
- // TODO
- }
|