|
|
|
@ -28,13 +28,13 @@ pub mod stream; |
|
|
|
|
use std::io::{Read, Write}; |
|
|
|
|
|
|
|
|
|
use compat::{cvt, AllowStd}; |
|
|
|
|
use futures::{Stream, Sink}; |
|
|
|
|
use futures::io::{AsyncRead, AsyncWrite}; |
|
|
|
|
use futures::{Sink, Stream}; |
|
|
|
|
use log::*; |
|
|
|
|
use pin_project::pin_project; |
|
|
|
|
use std::future::Future; |
|
|
|
|
use std::pin::Pin; |
|
|
|
|
use std::task::{Context, Poll}; |
|
|
|
|
use futures::io::{AsyncRead, AsyncWrite}; |
|
|
|
|
|
|
|
|
|
use tungstenite::{ |
|
|
|
|
error::Error as WsError, |
|
|
|
@ -310,7 +310,9 @@ impl<T> Sink<Message> for WebSocketStream<T> |
|
|
|
|
fn start_send(mut self: Pin<&mut Self>, item: Message) -> Result<(), Self::Error> { |
|
|
|
|
match (*self).with_context(None, |s| s.write_message(item)) { |
|
|
|
|
Ok(()) => Ok(()), |
|
|
|
|
Err(::tungstenite::Error::Io(ref err)) if err.kind() == std::io::ErrorKind::WouldBlock => { |
|
|
|
|
Err(::tungstenite::Error::Io(ref err)) |
|
|
|
|
if err.kind() == std::io::ErrorKind::WouldBlock => |
|
|
|
|
{ |
|
|
|
|
// the message was accepted and queued
|
|
|
|
|
// isn't an error.
|
|
|
|
|
Ok(()) |
|
|
|
@ -354,7 +356,10 @@ where |
|
|
|
|
fn poll(self: Pin<&mut Self>, cx: &mut Context<'_>) -> Poll<Self::Output> { |
|
|
|
|
let this = self.project(); |
|
|
|
|
let message = this.message.take().expect("Cannot poll twice"); |
|
|
|
|
Poll::Ready(this.stream.with_context(Some(cx), |s| s.write_message(message))) |
|
|
|
|
Poll::Ready( |
|
|
|
|
this.stream |
|
|
|
|
.with_context(Some(cx), |s| s.write_message(message)), |
|
|
|
|
) |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
@ -384,8 +389,8 @@ mod tests { |
|
|
|
|
#[cfg(feature = "connect")] |
|
|
|
|
use crate::connect::encryption::AutoStream; |
|
|
|
|
use crate::WebSocketStream; |
|
|
|
|
use std::io::{Read, Write}; |
|
|
|
|
use futures::io::{AsyncReadExt, AsyncWriteExt}; |
|
|
|
|
use std::io::{Read, Write}; |
|
|
|
|
|
|
|
|
|
fn is_read<T: Read>() {} |
|
|
|
|
fn is_write<T: Write>() {} |
|
|
|
|