mirror of
https://github.com/tokio-rs/tokio.git
synced 2026-09-06 00:00:10 +02:00
fs: document performance considerations (#3920)
This commit is contained in:
@@ -5,7 +5,7 @@
|
|||||||
rust_2018_idioms,
|
rust_2018_idioms,
|
||||||
unreachable_pub
|
unreachable_pub
|
||||||
)]
|
)]
|
||||||
#![cfg_attr(docsrs, deny(broken_intra_doc_links))]
|
#![cfg_attr(docsrs, deny(rustdoc::broken_intra_doc_links))]
|
||||||
#![doc(test(
|
#![doc(test(
|
||||||
no_crate_inject,
|
no_crate_inject,
|
||||||
attr(deny(warnings, rust_2018_idioms), allow(dead_code, unused_variables))
|
attr(deny(warnings, rust_2018_idioms), allow(dead_code, unused_variables))
|
||||||
|
|||||||
@@ -10,7 +10,7 @@
|
|||||||
unreachable_pub
|
unreachable_pub
|
||||||
)]
|
)]
|
||||||
#![cfg_attr(docsrs, feature(doc_cfg))]
|
#![cfg_attr(docsrs, feature(doc_cfg))]
|
||||||
#![cfg_attr(docsrs, deny(broken_intra_doc_links))]
|
#![cfg_attr(docsrs, deny(rustdoc::broken_intra_doc_links))]
|
||||||
#![doc(test(
|
#![doc(test(
|
||||||
no_crate_inject,
|
no_crate_inject,
|
||||||
attr(deny(warnings, rust_2018_idioms), allow(dead_code, unused_variables))
|
attr(deny(warnings, rust_2018_idioms), allow(dead_code, unused_variables))
|
||||||
|
|||||||
@@ -4,7 +4,7 @@
|
|||||||
rust_2018_idioms,
|
rust_2018_idioms,
|
||||||
unreachable_pub
|
unreachable_pub
|
||||||
)]
|
)]
|
||||||
#![cfg_attr(docsrs, deny(broken_intra_doc_links))]
|
#![cfg_attr(docsrs, deny(rustdoc::broken_intra_doc_links))]
|
||||||
#![doc(test(
|
#![doc(test(
|
||||||
no_crate_inject,
|
no_crate_inject,
|
||||||
attr(deny(warnings, rust_2018_idioms), allow(dead_code, unused_variables))
|
attr(deny(warnings, rust_2018_idioms), allow(dead_code, unused_variables))
|
||||||
|
|||||||
@@ -5,7 +5,7 @@
|
|||||||
rust_2018_idioms,
|
rust_2018_idioms,
|
||||||
unreachable_pub
|
unreachable_pub
|
||||||
)]
|
)]
|
||||||
#![cfg_attr(docsrs, deny(broken_intra_doc_links))]
|
#![cfg_attr(docsrs, deny(rustdoc::broken_intra_doc_links))]
|
||||||
#![doc(test(
|
#![doc(test(
|
||||||
no_crate_inject,
|
no_crate_inject,
|
||||||
attr(deny(warnings, rust_2018_idioms), allow(dead_code, unused_variables))
|
attr(deny(warnings, rust_2018_idioms), allow(dead_code, unused_variables))
|
||||||
|
|||||||
@@ -13,8 +13,12 @@ use std::{io, path::Path};
|
|||||||
/// buffer based on the file size when available, so it is generally faster than
|
/// buffer based on the file size when available, so it is generally faster than
|
||||||
/// reading into a vector created with `Vec::new()`.
|
/// reading into a vector created with `Vec::new()`.
|
||||||
///
|
///
|
||||||
|
/// This operation is implemented by running the equivalent blocking operation
|
||||||
|
/// on a separate thread pool using [`spawn_blocking`].
|
||||||
|
///
|
||||||
/// [`File::open`]: super::File::open
|
/// [`File::open`]: super::File::open
|
||||||
/// [`read_to_end`]: crate::io::AsyncReadExt::read_to_end
|
/// [`read_to_end`]: crate::io::AsyncReadExt::read_to_end
|
||||||
|
/// [`spawn_blocking`]: crate::task::spawn_blocking
|
||||||
///
|
///
|
||||||
/// # Errors
|
/// # Errors
|
||||||
///
|
///
|
||||||
|
|||||||
@@ -13,6 +13,11 @@ use std::task::Poll;
|
|||||||
/// Returns a stream over the entries within a directory.
|
/// Returns a stream over the entries within a directory.
|
||||||
///
|
///
|
||||||
/// This is an async version of [`std::fs::read_dir`](std::fs::read_dir)
|
/// This is an async version of [`std::fs::read_dir`](std::fs::read_dir)
|
||||||
|
///
|
||||||
|
/// This operation is implemented by running the equivalent blocking
|
||||||
|
/// operation on a separate thread pool using [`spawn_blocking`].
|
||||||
|
///
|
||||||
|
/// [`spawn_blocking`]: crate::task::spawn_blocking
|
||||||
pub async fn read_dir(path: impl AsRef<Path>) -> io::Result<ReadDir> {
|
pub async fn read_dir(path: impl AsRef<Path>) -> io::Result<ReadDir> {
|
||||||
let path = path.as_ref().to_owned();
|
let path = path.as_ref().to_owned();
|
||||||
let std = asyncify(|| std::fs::read_dir(path)).await?;
|
let std = asyncify(|| std::fs::read_dir(path)).await?;
|
||||||
|
|||||||
@@ -7,6 +7,10 @@ use std::{io, path::Path};
|
|||||||
///
|
///
|
||||||
/// This is the async equivalent of [`std::fs::read_to_string`][std].
|
/// This is the async equivalent of [`std::fs::read_to_string`][std].
|
||||||
///
|
///
|
||||||
|
/// This operation is implemented by running the equivalent blocking operation
|
||||||
|
/// on a separate thread pool using [`spawn_blocking`].
|
||||||
|
///
|
||||||
|
/// [`spawn_blocking`]: crate::task::spawn_blocking
|
||||||
/// [std]: fn@std::fs::read_to_string
|
/// [std]: fn@std::fs::read_to_string
|
||||||
///
|
///
|
||||||
/// # Examples
|
/// # Examples
|
||||||
|
|||||||
@@ -7,6 +7,10 @@ use std::{io, path::Path};
|
|||||||
///
|
///
|
||||||
/// This is the async equivalent of [`std::fs::write`][std].
|
/// This is the async equivalent of [`std::fs::write`][std].
|
||||||
///
|
///
|
||||||
|
/// This operation is implemented by running the equivalent blocking operation
|
||||||
|
/// on a separate thread pool using [`spawn_blocking`].
|
||||||
|
///
|
||||||
|
/// [`spawn_blocking`]: crate::task::spawn_blocking
|
||||||
/// [std]: fn@std::fs::write
|
/// [std]: fn@std::fs::write
|
||||||
///
|
///
|
||||||
/// # Examples
|
/// # Examples
|
||||||
|
|||||||
+1
-1
@@ -10,7 +10,7 @@
|
|||||||
unreachable_pub
|
unreachable_pub
|
||||||
)]
|
)]
|
||||||
#![deny(unused_must_use)]
|
#![deny(unused_must_use)]
|
||||||
#![cfg_attr(docsrs, deny(broken_intra_doc_links))]
|
#![cfg_attr(docsrs, deny(rustdoc::broken_intra_doc_links))]
|
||||||
#![doc(test(
|
#![doc(test(
|
||||||
no_crate_inject,
|
no_crate_inject,
|
||||||
attr(deny(warnings, rust_2018_idioms), allow(dead_code, unused_variables))
|
attr(deny(warnings, rust_2018_idioms), allow(dead_code, unused_variables))
|
||||||
|
|||||||
Reference in New Issue
Block a user