mirror of
https://github.com/async-rs/async-std.git
synced 2025-03-05 01:29:43 +00:00
refactor io dir to be same with std
This commit is contained in:
parent
f611ceccc8
commit
9d634cb2a7
3 changed files with 6 additions and 8 deletions
|
@ -4,11 +4,9 @@ use std::{cmp, fmt};
|
||||||
|
|
||||||
use pin_project_lite::pin_project;
|
use pin_project_lite::pin_project;
|
||||||
|
|
||||||
use crate::io::{self, BufRead, Read, Seek, SeekFrom};
|
use crate::io::{self, BufRead, Read, Seek, SeekFrom, DEFAULT_BUF_SIZE};
|
||||||
use crate::task::{Context, Poll};
|
use crate::task::{Context, Poll};
|
||||||
|
|
||||||
const DEFAULT_CAPACITY: usize = 8 * 1024;
|
|
||||||
|
|
||||||
pin_project! {
|
pin_project! {
|
||||||
/// Adds buffering to any reader.
|
/// Adds buffering to any reader.
|
||||||
///
|
///
|
||||||
|
@ -72,7 +70,7 @@ impl<R: io::Read> BufReader<R> {
|
||||||
/// # Ok(()) }) }
|
/// # Ok(()) }) }
|
||||||
/// ```
|
/// ```
|
||||||
pub fn new(inner: R) -> BufReader<R> {
|
pub fn new(inner: R) -> BufReader<R> {
|
||||||
BufReader::with_capacity(DEFAULT_CAPACITY, inner)
|
BufReader::with_capacity(DEFAULT_BUF_SIZE, inner)
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Creates a new buffered reader with the specified capacity.
|
/// Creates a new buffered reader with the specified capacity.
|
||||||
|
|
|
@ -4,11 +4,9 @@ use std::pin::Pin;
|
||||||
use pin_project_lite::pin_project;
|
use pin_project_lite::pin_project;
|
||||||
|
|
||||||
use crate::io::write::WriteExt;
|
use crate::io::write::WriteExt;
|
||||||
use crate::io::{self, Seek, SeekFrom, Write};
|
use crate::io::{self, Seek, SeekFrom, Write, DEFAULT_BUF_SIZE};
|
||||||
use crate::task::{Context, Poll, ready};
|
use crate::task::{Context, Poll, ready};
|
||||||
|
|
||||||
const DEFAULT_CAPACITY: usize = 8 * 1024;
|
|
||||||
|
|
||||||
pin_project! {
|
pin_project! {
|
||||||
/// Wraps a writer and buffers its output.
|
/// Wraps a writer and buffers its output.
|
||||||
///
|
///
|
||||||
|
@ -107,7 +105,7 @@ impl<W: Write> BufWriter<W> {
|
||||||
/// # Ok(()) }) }
|
/// # Ok(()) }) }
|
||||||
/// ```
|
/// ```
|
||||||
pub fn new(inner: W) -> BufWriter<W> {
|
pub fn new(inner: W) -> BufWriter<W> {
|
||||||
BufWriter::with_capacity(DEFAULT_CAPACITY, inner)
|
BufWriter::with_capacity(DEFAULT_BUF_SIZE, inner)
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Creates a new `BufWriter` with the specified buffer capacity.
|
/// Creates a new `BufWriter` with the specified buffer capacity.
|
||||||
|
|
|
@ -269,6 +269,8 @@
|
||||||
//! [`Result`]: https://doc.rust-lang.org/std/result/enum.Result.html
|
//! [`Result`]: https://doc.rust-lang.org/std/result/enum.Result.html
|
||||||
//! [`.unwrap()`]: https://doc.rust-lang.org/std/result/enum.Result.html#method.unwrap
|
//! [`.unwrap()`]: https://doc.rust-lang.org/std/result/enum.Result.html#method.unwrap
|
||||||
|
|
||||||
|
const DEFAULT_BUF_SIZE: usize = 8 * 1024;
|
||||||
|
|
||||||
cfg_std! {
|
cfg_std! {
|
||||||
#[doc(inline)]
|
#[doc(inline)]
|
||||||
pub use std::io::{Error, ErrorKind, IoSlice, IoSliceMut, Result, SeekFrom};
|
pub use std::io::{Error, ErrorKind, IoSlice, IoSliceMut, Result, SeekFrom};
|
||||||
|
|
Loading…
Reference in a new issue