mirror of
https://github.com/tokio-rs/tokio.git
synced 2026-08-29 00:00:11 +02:00
buf: Inital pass at updating BufStream (#1355)
This commit is contained in:
+1
-1
@@ -2,7 +2,7 @@
|
|||||||
|
|
||||||
members = [
|
members = [
|
||||||
"tokio",
|
"tokio",
|
||||||
# "tokio-buf",
|
"tokio-buf",
|
||||||
"tokio-codec",
|
"tokio-codec",
|
||||||
"tokio-current-thread",
|
"tokio-current-thread",
|
||||||
"tokio-executor",
|
"tokio-executor",
|
||||||
|
|||||||
@@ -24,11 +24,10 @@ publish = false
|
|||||||
[dependencies]
|
[dependencies]
|
||||||
bytes = "0.4.10"
|
bytes = "0.4.10"
|
||||||
either = { version = "1.5", optional = true}
|
either = { version = "1.5", optional = true}
|
||||||
futures = "0.1.23"
|
|
||||||
|
|
||||||
[features]
|
[features]
|
||||||
default = ["util"]
|
# default = ["util"]
|
||||||
util = ["bytes/either", "either"]
|
# util = ["bytes/either", "either"]
|
||||||
|
|
||||||
[dev-dependencies]
|
[dev-dependencies]
|
||||||
tokio-mock-task = "0.1.1"
|
tokio-mock-task = "0.1.1"
|
||||||
|
|||||||
+10
-10
@@ -15,20 +15,20 @@
|
|||||||
//! instead of yielding arbitrary values, it only yields types that implement
|
//! instead of yielding arbitrary values, it only yields types that implement
|
||||||
//! `Buf` (i.e, byte collections).
|
//! `Buf` (i.e, byte collections).
|
||||||
|
|
||||||
mod never;
|
// mod never;
|
||||||
mod size_hint;
|
mod size_hint;
|
||||||
mod str;
|
// mod str;
|
||||||
mod u8;
|
// mod u8;
|
||||||
#[cfg(feature = "util")]
|
// #[cfg(feature = "util")]
|
||||||
pub mod util;
|
// pub mod util;
|
||||||
|
|
||||||
pub use self::size_hint::SizeHint;
|
pub use self::size_hint::SizeHint;
|
||||||
#[doc(inline)]
|
// #[doc(inline)]
|
||||||
#[cfg(feature = "util")]
|
// #[cfg(feature = "util")]
|
||||||
pub use crate::util::BufStreamExt;
|
// pub use crate::util::BufStreamExt;
|
||||||
|
|
||||||
use bytes::Buf;
|
use bytes::Buf;
|
||||||
use futures::Poll;
|
use std::task::{Context, Poll};
|
||||||
|
|
||||||
/// An asynchronous stream of bytes.
|
/// An asynchronous stream of bytes.
|
||||||
///
|
///
|
||||||
@@ -68,7 +68,7 @@ pub trait BufStream {
|
|||||||
///
|
///
|
||||||
/// Once a stream is finished, i.e. `Ready(None)` has been returned, further
|
/// Once a stream is finished, i.e. `Ready(None)` has been returned, further
|
||||||
/// calls to `poll_buf` may result in a panic or other "bad behavior".
|
/// calls to `poll_buf` may result in a panic or other "bad behavior".
|
||||||
fn poll_buf(&mut self) -> Poll<Option<Self::Item>, Self::Error>;
|
fn poll_buf(&mut self, cx: &mut Context<'_>) -> Poll<Option<Result<Self::Item, Self::Error>>>;
|
||||||
|
|
||||||
/// Returns the bounds on the remaining length of the stream.
|
/// Returns the bounds on the remaining length of the stream.
|
||||||
///
|
///
|
||||||
|
|||||||
@@ -1,5 +1,8 @@
|
|||||||
use tokio_buf::BufStream;
|
use tokio_buf::BufStream;
|
||||||
|
|
||||||
// Ensures that `BufStream` can be a trait object
|
#[test]
|
||||||
#[allow(dead_code)]
|
fn object_safe() {
|
||||||
fn obj(_: &mut dyn BufStream<Item = u32, Error = ()>) {}
|
// Ensures that `BufStream` can be a trait object
|
||||||
|
#[allow(dead_code)]
|
||||||
|
fn obj(_: &mut dyn BufStream<Item = u32, Error = ()>) {}
|
||||||
|
}
|
||||||
|
|||||||
@@ -1,3 +1,4 @@
|
|||||||
|
#![cfg(feature = "broken")]
|
||||||
#![cfg(feature = "util")]
|
#![cfg(feature = "util")]
|
||||||
|
|
||||||
use futures::Async::*;
|
use futures::Async::*;
|
||||||
|
|||||||
@@ -1,3 +1,4 @@
|
|||||||
|
#![cfg(feature = "broken")]
|
||||||
#![cfg(feature = "util")]
|
#![cfg(feature = "util")]
|
||||||
|
|
||||||
use bytes::Bytes;
|
use bytes::Bytes;
|
||||||
|
|||||||
@@ -1,3 +1,4 @@
|
|||||||
|
#![cfg(feature = "broken")]
|
||||||
use futures::Async::*;
|
use futures::Async::*;
|
||||||
use std::io::Cursor;
|
use std::io::Cursor;
|
||||||
use tokio_buf::{util, BufStream};
|
use tokio_buf::{util, BufStream};
|
||||||
|
|||||||
@@ -1,3 +1,4 @@
|
|||||||
|
#![cfg(feature = "broken")]
|
||||||
#![cfg(feature = "util")]
|
#![cfg(feature = "util")]
|
||||||
|
|
||||||
use futures::Async::*;
|
use futures::Async::*;
|
||||||
|
|||||||
@@ -1,3 +1,4 @@
|
|||||||
|
#![cfg(feature = "broken")]
|
||||||
use futures::sync::mpsc;
|
use futures::sync::mpsc;
|
||||||
use futures::Async::*;
|
use futures::Async::*;
|
||||||
use std::io::Cursor;
|
use std::io::Cursor;
|
||||||
|
|||||||
@@ -1,3 +1,4 @@
|
|||||||
|
#![cfg(feature = "broken")]
|
||||||
use futures::Async::*;
|
use futures::Async::*;
|
||||||
use std::fmt;
|
use std::fmt;
|
||||||
use tokio_buf::BufStream;
|
use tokio_buf::BufStream;
|
||||||
|
|||||||
@@ -1,3 +1,4 @@
|
|||||||
|
#![cfg(feature = "broken")]
|
||||||
#![allow(unused)]
|
#![allow(unused)]
|
||||||
|
|
||||||
use bytes::Buf;
|
use bytes::Buf;
|
||||||
|
|||||||
Reference in New Issue
Block a user