diff options
| author | bors <bors@rust-lang.org> | 2015-03-13 20:22:16 +0000 |
|---|---|---|
| committer | bors <bors@rust-lang.org> | 2015-03-13 20:22:16 +0000 |
| commit | 3e4be02b80a3dd27bce20870958fe0aef7e7336d (patch) | |
| tree | 156b54e84eeb1df2818be29b53ab7f35b5bc80f0 /src/libstd/sys/unix/mod.rs | |
| parent | 9eb69abad8ffbce840e7dc7038ddea434dc987f1 (diff) | |
| parent | 981bf5f690d1d7c5cf3e1419ac7a7c86dbc7a4d5 (diff) | |
| download | rust-3e4be02b80a3dd27bce20870958fe0aef7e7336d.tar.gz rust-3e4be02b80a3dd27bce20870958fe0aef7e7336d.zip | |
Auto merge of #23292 - alexcrichton:stabilize-io, r=aturon
The new `std::io` module has had some time to bake now, and this commit
stabilizes its functionality. There are still portions of the module which
remain unstable, and below contains a summart of the actions taken.
This commit also deprecates the entire contents of the `old_io` module in a
blanket fashion. All APIs should now have a reasonable replacement in the
new I/O modules.
Stable APIs:
* `std::io` (the name)
* `std::io::prelude` (the name)
* `Read`
* `Read::read`
* `Read::{read_to_end, read_to_string}` after being modified to return a `usize`
for the number of bytes read.
* `ReadExt`
* `Write`
* `Write::write`
* `Write::{write_all, write_fmt}`
* `WriteExt`
* `BufRead`
* `BufRead::{fill_buf, consume}`
* `BufRead::{read_line, read_until}` after being modified to return a `usize`
for the number of bytes read.
* `BufReadExt`
* `BufReader`
* `BufReader::{new, with_capacity}`
* `BufReader::{get_ref, get_mut, into_inner}`
* `{Read,BufRead} for BufReader`
* `BufWriter`
* `BufWriter::{new, with_capacity}`
* `BufWriter::{get_ref, get_mut, into_inner}`
* `Write for BufWriter`
* `IntoInnerError`
* `IntoInnerError::{error, into_inner}`
* `{Error,Display} for IntoInnerError`
* `LineWriter`
* `LineWriter::{new, with_capacity}` - `with_capacity` was added
* `LineWriter::{get_ref, get_mut, into_inner}` - `get_mut` was added)
* `Write for LineWriter`
* `BufStream`
* `BufStream::{new, with_capacities}`
* `BufStream::{get_ref, get_mut, into_inner}`
* `{BufRead,Read,Write} for BufStream`
* `stdin`
* `Stdin`
* `Stdin::lock`
* `Stdin::read_line` - added method
* `StdinLock`
* `Read for Stdin`
* `{Read,BufRead} for StdinLock`
* `stdout`
* `Stdout`
* `Stdout::lock`
* `StdoutLock`
* `Write for Stdout`
* `Write for StdoutLock`
* `stderr`
* `Stderr`
* `Stderr::lock`
* `StderrLock`
* `Write for Stderr`
* `Write for StderrLock`
* `io::Result`
* `io::Error`
* `io::Error::last_os_error`
* `{Display, Error} for Error`
Unstable APIs:
(reasons can be found in the commit itself)
* `Write::flush`
* `Seek`
* `ErrorKind`
* `Error::new`
* `Error::from_os_error`
* `Error::kind`
Deprecated APIs
* `Error::description` - available via the `Error` trait
* `Error::detail` - available via the `Display` implementation
* `thread::Builder::{stdout, stderr}`
Changes in functionality:
* `old_io::stdio::set_stderr` is now a noop as the infrastructure for printing
backtraces has migrated to `std::io`.
[breaking-change]
Diffstat (limited to 'src/libstd/sys/unix/mod.rs')
| -rw-r--r-- | src/libstd/sys/unix/mod.rs | 9 |
1 files changed, 9 insertions, 0 deletions
diff --git a/src/libstd/sys/unix/mod.rs b/src/libstd/sys/unix/mod.rs index 865ea987279..a8cee74828d 100644 --- a/src/libstd/sys/unix/mod.rs +++ b/src/libstd/sys/unix/mod.rs @@ -60,10 +60,12 @@ pub type wrlen = libc::size_t; pub type msglen_t = libc::size_t; pub unsafe fn close_sock(sock: sock_t) { let _ = libc::close(sock); } +#[allow(deprecated)] pub fn last_error() -> IoError { decode_error_detailed(os::errno() as i32) } +#[allow(deprecated)] pub fn last_net_error() -> IoError { last_error() } @@ -72,6 +74,7 @@ extern "system" { fn gai_strerror(errcode: libc::c_int) -> *const libc::c_char; } +#[allow(deprecated)] pub fn last_gai_error(s: libc::c_int) -> IoError { let mut err = decode_error(s); @@ -83,6 +86,7 @@ pub fn last_gai_error(s: libc::c_int) -> IoError { } /// Convert an `errno` value into a high-level error variant and description. +#[allow(deprecated)] pub fn decode_error(errno: i32) -> IoError { // FIXME: this should probably be a bit more descriptive... let (kind, desc) = match errno { @@ -119,12 +123,14 @@ pub fn decode_error(errno: i32) -> IoError { IoError { kind: kind, desc: desc, detail: None } } +#[allow(deprecated)] pub fn decode_error_detailed(errno: i32) -> IoError { let mut err = decode_error(errno); err.detail = Some(os::error_string(errno)); err } +#[allow(deprecated)] pub fn decode_error_kind(errno: i32) -> ErrorKind { match errno as libc::c_int { libc::ECONNREFUSED => ErrorKind::ConnectionRefused, @@ -155,6 +161,7 @@ pub fn decode_error_kind(errno: i32) -> ErrorKind { } #[inline] +#[allow(deprecated)] pub fn retry<T, F> (mut f: F) -> T where T: SignedInt, F: FnMut() -> T, @@ -194,11 +201,13 @@ pub fn ms_to_timeval(ms: u64) -> libc::timeval { } } +#[allow(deprecated)] pub fn wouldblock() -> bool { let err = os::errno(); err == libc::EWOULDBLOCK as i32 || err == libc::EAGAIN as i32 } +#[allow(deprecated)] pub fn set_nonblocking(fd: sock_t, nb: bool) { let set = nb as libc::c_int; mkerr_libc(retry(|| unsafe { c::ioctl(fd, c::FIONBIO, &set) })).unwrap(); |
