mirror of
https://github.com/tokio-rs/tokio.git
synced 2025-10-01 12:20:39 +00:00
chore: make #[doc(hidden)] apis private (#2901)
This commit is contained in:
parent
13de30c53e
commit
7ec6d88b21
@ -55,8 +55,7 @@ impl ReadDir {
|
||||
poll_fn(|cx| self.poll_next_entry(cx)).await
|
||||
}
|
||||
|
||||
#[doc(hidden)]
|
||||
pub fn poll_next_entry(&mut self, cx: &mut Context<'_>) -> Poll<io::Result<Option<DirEntry>>> {
|
||||
fn poll_next_entry(&mut self, cx: &mut Context<'_>) -> Poll<io::Result<Option<DirEntry>>> {
|
||||
loop {
|
||||
match self.0 {
|
||||
State::Idle(ref mut std) => {
|
||||
|
@ -83,8 +83,7 @@ impl<R> Lines<R>
|
||||
where
|
||||
R: AsyncBufRead,
|
||||
{
|
||||
#[doc(hidden)]
|
||||
pub fn poll_next_line(
|
||||
fn poll_next_line(
|
||||
self: Pin<&mut Self>,
|
||||
cx: &mut Context<'_>,
|
||||
) -> Poll<io::Result<Option<String>>> {
|
||||
|
@ -65,8 +65,7 @@ impl<R> Split<R>
|
||||
where
|
||||
R: AsyncBufRead,
|
||||
{
|
||||
#[doc(hidden)]
|
||||
pub fn poll_next_segment(
|
||||
fn poll_next_segment(
|
||||
self: Pin<&mut Self>,
|
||||
cx: &mut Context<'_>,
|
||||
) -> Poll<io::Result<Option<Vec<u8>>>> {
|
||||
|
@ -23,9 +23,7 @@ macro_rules! scoped_thread_local {
|
||||
/// Type representing a thread local storage key corresponding to a reference
|
||||
/// to the type parameter `T`.
|
||||
pub(crate) struct ScopedKey<T> {
|
||||
#[doc(hidden)]
|
||||
pub(crate) inner: &'static LocalKey<Cell<*const ()>>,
|
||||
#[doc(hidden)]
|
||||
pub(crate) _marker: marker::PhantomData<T>,
|
||||
}
|
||||
|
||||
|
@ -192,9 +192,13 @@ impl TcpStream {
|
||||
Ok(TcpStream { io })
|
||||
}
|
||||
|
||||
// Connects `TcpStream` asynchronously that may be built with a net2 `TcpBuilder`.
|
||||
//
|
||||
// This should be removed in favor of some in-crate TcpSocket builder API.
|
||||
/// Connects `TcpStream` asynchronously that may be built with a net2 `TcpBuilder`.
|
||||
///
|
||||
/// This function is intended to be replaced with some sort of TcpSocket builder.
|
||||
/// See https://github.com/tokio-rs/tokio/issues/2902
|
||||
///
|
||||
/// Despite being hidden, this function is part of the public API of Tokio v0.3, but
|
||||
/// will be removed in v1.0 in favor of a better design.
|
||||
#[doc(hidden)]
|
||||
pub async fn connect_std(stream: net::TcpStream, addr: &SocketAddr) -> io::Result<TcpStream> {
|
||||
let io = mio::net::TcpStream::connect_stream(stream, addr)?;
|
||||
|
@ -196,8 +196,7 @@ impl<T> Sender<T> {
|
||||
Ok(())
|
||||
}
|
||||
|
||||
#[doc(hidden)] // TODO: remove
|
||||
pub fn poll_closed(&mut self, cx: &mut Context<'_>) -> Poll<()> {
|
||||
fn poll_closed(&mut self, cx: &mut Context<'_>) -> Poll<()> {
|
||||
// Keep track of task budget
|
||||
let coop = ready!(crate::coop::poll_proceed(cx));
|
||||
|
||||
|
@ -75,8 +75,10 @@ impl Future for OnClose<'_> {
|
||||
type Output = bool;
|
||||
|
||||
fn poll(self: Pin<&mut Self>, cx: &mut Context<'_>) -> Poll<bool> {
|
||||
let res = self.get_mut().tx.poll_closed(cx);
|
||||
Ready(res.is_ready())
|
||||
let fut = self.get_mut().tx.closed();
|
||||
crate::pin!(fut);
|
||||
|
||||
Ready(fut.poll(cx).is_ready())
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -122,8 +122,7 @@ pub struct Interval {
|
||||
}
|
||||
|
||||
impl Interval {
|
||||
#[doc(hidden)] // TODO: document
|
||||
pub fn poll_tick(&mut self, cx: &mut Context<'_>) -> Poll<Instant> {
|
||||
fn poll_tick(&mut self, cx: &mut Context<'_>) -> Poll<Instant> {
|
||||
// Wait for the delay to be done
|
||||
ready!(Pin::new(&mut self.delay).poll(cx));
|
||||
|
||||
|
@ -6,11 +6,24 @@ use tokio_test::*;
|
||||
|
||||
use std::future::Future;
|
||||
use std::pin::Pin;
|
||||
use std::task::{Context, Poll};
|
||||
|
||||
trait AssertSend: Send {}
|
||||
impl AssertSend for oneshot::Sender<i32> {}
|
||||
impl AssertSend for oneshot::Receiver<i32> {}
|
||||
|
||||
trait SenderExt {
|
||||
fn poll_closed(&mut self, cx: &mut Context<'_>) -> Poll<()>;
|
||||
}
|
||||
impl<T> SenderExt for oneshot::Sender<T> {
|
||||
fn poll_closed(&mut self, cx: &mut Context<'_>) -> Poll<()> {
|
||||
tokio::pin! {
|
||||
let fut = self.closed();
|
||||
}
|
||||
fut.poll(cx)
|
||||
}
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn send_recv() {
|
||||
let (tx, rx) = oneshot::channel();
|
||||
|
@ -4,6 +4,7 @@
|
||||
use tokio::time::{self, Duration, Instant};
|
||||
use tokio_test::{assert_pending, assert_ready_eq, task};
|
||||
|
||||
use std::future::Future;
|
||||
use std::task::Poll;
|
||||
|
||||
#[tokio::test]
|
||||
@ -58,7 +59,12 @@ async fn usage_stream() {
|
||||
}
|
||||
|
||||
fn poll_next(interval: &mut task::Spawn<time::Interval>) -> Poll<Instant> {
|
||||
interval.enter(|cx, mut interval| interval.poll_tick(cx))
|
||||
interval.enter(|cx, mut interval| {
|
||||
tokio::pin! {
|
||||
let fut = interval.tick();
|
||||
}
|
||||
fut.poll(cx)
|
||||
})
|
||||
}
|
||||
|
||||
fn ms(n: u64) -> Duration {
|
||||
|
Loading…
x
Reference in New Issue
Block a user