|
|
|
@ -1,3 +1,4 @@ |
|
|
|
|
#[allow(unused_imports)] |
|
|
|
|
use log::*; |
|
|
|
|
use std::io::{Read, Write}; |
|
|
|
|
use std::pin::Pin; |
|
|
|
@ -121,6 +122,7 @@ where |
|
|
|
|
where |
|
|
|
|
F: FnOnce(&mut Context<'_>, Pin<&mut S>) -> Poll<std::io::Result<R>>, |
|
|
|
|
{ |
|
|
|
|
#[cfg(feature = "verbose-logging")] |
|
|
|
|
trace!("{}:{} AllowStd.with_context", file!(), line!()); |
|
|
|
|
let waker = match kind { |
|
|
|
|
ContextWaker::Read => task::waker_ref(&self.read_waker_proxy), |
|
|
|
@ -144,8 +146,10 @@ where |
|
|
|
|
S: AsyncRead + Unpin, |
|
|
|
|
{ |
|
|
|
|
fn read(&mut self, buf: &mut [u8]) -> std::io::Result<usize> { |
|
|
|
|
#[cfg(feature = "verbose-logging")] |
|
|
|
|
trace!("{}:{} Read.read", file!(), line!()); |
|
|
|
|
match self.with_context(ContextWaker::Read, |ctx, stream| { |
|
|
|
|
#[cfg(feature = "verbose-logging")] |
|
|
|
|
trace!( |
|
|
|
|
"{}:{} Read.with_context read -> poll_read", |
|
|
|
|
file!(), |
|
|
|
@ -164,8 +168,10 @@ where |
|
|
|
|
S: AsyncWrite + Unpin, |
|
|
|
|
{ |
|
|
|
|
fn write(&mut self, buf: &[u8]) -> std::io::Result<usize> { |
|
|
|
|
#[cfg(feature = "verbose-logging")] |
|
|
|
|
trace!("{}:{} Write.write", file!(), line!()); |
|
|
|
|
match self.with_context(ContextWaker::Write, |ctx, stream| { |
|
|
|
|
#[cfg(feature = "verbose-logging")] |
|
|
|
|
trace!( |
|
|
|
|
"{}:{} Write.with_context write -> poll_write", |
|
|
|
|
file!(), |
|
|
|
@ -179,8 +185,10 @@ where |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
fn flush(&mut self) -> std::io::Result<()> { |
|
|
|
|
#[cfg(feature = "verbose-logging")] |
|
|
|
|
trace!("{}:{} Write.flush", file!(), line!()); |
|
|
|
|
match self.with_context(ContextWaker::Write, |ctx, stream| { |
|
|
|
|
#[cfg(feature = "verbose-logging")] |
|
|
|
|
trace!( |
|
|
|
|
"{}:{} Write.with_context flush -> poll_flush", |
|
|
|
|
file!(), |
|
|
|
@ -198,6 +206,7 @@ pub(crate) fn cvt<T>(r: Result<T, WsError>) -> Poll<Result<T, WsError>> { |
|
|
|
|
match r { |
|
|
|
|
Ok(v) => Poll::Ready(Ok(v)), |
|
|
|
|
Err(WsError::Io(ref e)) if e.kind() == std::io::ErrorKind::WouldBlock => { |
|
|
|
|
#[cfg(feature = "verbose-logging")] |
|
|
|
|
trace!("WouldBlock"); |
|
|
|
|
Poll::Pending |
|
|
|
|
} |
|
|
|
|