Derive some std::fmt::Debug impls. (#1226)

* Derive some `Debug` impls.

* And some more.

Also remove several #[inline] attributes.
This commit is contained in:
Toralf Wittner 2019-08-19 20:15:56 +02:00 committed by GitHub
parent bf8c97049a
commit c0b379b908
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 14 additions and 7 deletions

View File

@ -28,7 +28,6 @@ use tokio_io::{io, AsyncRead, AsyncWrite};
///
/// > **Note**: Prepends a variable-length prefix indicate the length of the message. This is
/// > compatible with what `read_one` expects.
#[inline]
pub fn write_one<TSocket, TData>(socket: TSocket, data: TData) -> WriteOne<TSocket, TData>
where
TSocket: AsyncWrite,
@ -50,10 +49,12 @@ fn build_int_buffer(num: usize) -> io::Window<[u8; 10]> {
}
/// Future that makes `write_one` work.
#[derive(Debug)]
pub struct WriteOne<TSocket, TData = Vec<u8>> {
inner: WriteOneInner<TSocket, TData>,
}
#[derive(Debug)]
enum WriteOneInner<TSocket, TData> {
/// We need to write the data length to the socket.
WriteLen(io::WriteAll<TSocket, io::Window<[u8; 10]>>, TData),
@ -73,7 +74,6 @@ where
type Item = ();
type Error = std::io::Error;
#[inline]
fn poll(&mut self) -> Poll<Self::Item, Self::Error> {
Ok(self.inner.poll()?.map(|_socket| ()))
}
@ -125,7 +125,6 @@ where
///
/// > **Note**: Assumes that a variable-length prefix indicates the length of the message. This is
/// > compatible with what `write_one` does.
#[inline]
pub fn read_one<TSocket>(
socket: TSocket,
max_size: usize,
@ -141,10 +140,12 @@ pub fn read_one<TSocket>(
}
/// Future that makes `read_one` work.
#[derive(Debug)]
pub struct ReadOne<TSocket> {
inner: ReadOneInner<TSocket>,
}
#[derive(Debug)]
enum ReadOneInner<TSocket> {
// We need to read the data length from the socket.
ReadLen {
@ -272,7 +273,6 @@ pub enum ReadOneError {
}
impl From<std::io::Error> for ReadOneError {
#[inline]
fn from(err: std::io::Error) -> ReadOneError {
ReadOneError::Io(err)
}
@ -303,7 +303,6 @@ impl error::Error for ReadOneError {
/// > ownership of any data we want. In practice, though, this would make the
/// > `ReadRespond` type impossible to express as a concrete type. Once the `impl Trait`
/// > syntax is allowed within traits, we can remove this parameter.
#[inline]
pub fn read_one_then<TSocket, TParam, TThen, TOut, TErr>(
socket: TSocket,
max_size: usize,
@ -322,6 +321,7 @@ where
}
/// Future that makes `read_one_then` work.
#[derive(Debug)]
pub struct ReadOneThen<TSocket, TParam, TThen> {
inner: ReadOne<TSocket>,
then: Option<(TParam, TThen)>,
@ -355,7 +355,6 @@ where
/// > ownership of any data we want. In practice, though, this would make the
/// > `ReadRespond` type impossible to express as a concrete type. Once the `impl Trait`
/// > syntax is allowed within traits, we can remove this parameter.
#[inline]
pub fn read_respond<TSocket, TThen, TParam, TOut, TErr>(
socket: TSocket,
max_size: usize,
@ -374,6 +373,7 @@ where
}
/// Future that makes `read_respond` work.
#[derive(Debug)]
pub struct ReadRespond<TSocket, TParam, TThen> {
inner: ReadOneInner<TSocket>,
then: Option<(TThen, TParam)>,
@ -408,7 +408,6 @@ where
/// > ownership of any data we want. In practice, though, this would make the
/// > `ReadRespond` type impossible to express as a concrete type. Once the `impl Trait`
/// > syntax is allowed within traits, we can remove this parameter.
#[inline]
pub fn request_response<TSocket, TData, TParam, TThen, TOut, TErr>(
socket: TSocket,
data: TData,
@ -427,10 +426,12 @@ where
}
/// Future that makes `request_response` work.
#[derive(Debug)]
pub struct RequestResponse<TSocket, TParam, TThen, TData = Vec<u8>> {
inner: RequestResponseInner<TSocket, TData, TParam, TThen>,
}
#[derive(Debug)]
enum RequestResponseInner<TSocket, TData, TParam, TThen> {
// We need to write data to the socket.
Write(WriteOneInner<TSocket, TData>, usize, TParam, TThen),

View File

@ -34,6 +34,7 @@ const DEFAULT_BUFFER_SIZE: usize = 64;
/// We purposely only support a frame sizes up to 16KiB (2 bytes unsigned varint
/// frame length). Frames mostly consist in a short protocol name, which is highly
/// unlikely to be more than 16KiB long.
#[derive(Debug)]
pub struct LengthDelimited<R> {
/// The inner I/O resource.
inner: R,
@ -269,6 +270,7 @@ where
/// A `LengthDelimitedReader` implements a `Stream` of uvi-length-delimited
/// frames on an underlying I/O resource combined with direct `AsyncWrite` access.
#[derive(Debug)]
pub struct LengthDelimitedReader<R> {
inner: LengthDelimited<R>
}

View File

@ -36,11 +36,13 @@ use std::{mem, io, fmt, error::Error};
///
/// Reading from a `Negotiated` I/O stream that still has pending negotiation
/// protocol data to send implicitly triggers flushing of all yet unsent data.
#[derive(Debug)]
pub struct Negotiated<TInner> {
state: State<TInner>
}
/// A `Future` that waits on the completion of protocol negotiation.
#[derive(Debug)]
pub struct NegotiatedComplete<TInner> {
inner: Option<Negotiated<TInner>>
}
@ -146,6 +148,7 @@ impl<TInner> Negotiated<TInner> {
}
/// The states of a `Negotiated` I/O stream.
#[derive(Debug)]
enum State<R> {
/// In this state, a `Negotiated` is still expecting to
/// receive confirmation of the protocol it as settled on.

View File

@ -297,6 +297,7 @@ where
/// A `MessageReader` implements a `Stream` of `Message`s on an underlying
/// I/O resource combined with direct `AsyncWrite` access.
#[derive(Debug)]
pub struct MessageReader<R> {
inner: LengthDelimitedReader<R>
}