Skip to content

Commit 32a548d

Browse files
committed
std: Rename io to old_io
In preparation for the I/O rejuvination of the standard library, this commit renames the current `io` module to `old_io` in order to make room for the new I/O modules. It is expected that the I/O RFCs will land incrementally over time instead of all at once, and this provides a fresh clean path for new modules to enter into as well as guaranteeing that all old infrastructure will remain in place for some time. As each `old_io` module is replaced it will be deprecated in-place for new structures in `std::{io, fs, net}` (as appropriate). This commit does *not* leave a reexport of `old_io as io` as the deprecation lint does not currently warn on this form of use. This is quite a large breaking change for all imports in existing code, but all functionality is retained precisely as-is and path statements simply need to be renamed from `io` to `old_io`. [breaking-change]
1 parent 76fbb35 commit 32a548d

21 files changed

+311
-291
lines changed

src/libstd/lib.rs

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -79,7 +79,8 @@
7979
//! memory types, including [`atomic`](sync/atomic/index.html).
8080
//!
8181
//! Common types of I/O, including files, TCP, UDP, pipes, Unix domain sockets,
82-
//! timers, and process spawning, are defined in the [`io`](io/index.html) module.
82+
//! timers, and process spawning, are defined in the
83+
//! [`old_io`](old_io/index.html) module.
8384
//!
8485
//! Rust's I/O and concurrency depends on a small runtime interface
8586
//! that lives, along with its support code, in mod [`rt`](rt/index.html).
@@ -239,7 +240,7 @@ pub mod thread_local;
239240
pub mod dynamic_lib;
240241
pub mod ffi;
241242
pub mod fmt;
242-
pub mod io;
243+
pub mod old_io;
243244
pub mod os;
244245
pub mod path;
245246
pub mod rand;
@@ -284,7 +285,7 @@ mod std {
284285
pub use sync; // used for select!()
285286
pub use error; // used for try!()
286287
pub use fmt; // used for any formatting strings
287-
pub use io; // used for println!()
288+
pub use old_io; // used for println!()
288289
pub use option; // used for bitflags!{}
289290
pub use rt; // used for panic!()
290291
pub use vec; // used for vec![]

src/libstd/io/buffered.rs renamed to src/libstd/old_io/buffered.rs

Lines changed: 15 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414
1515
use cmp;
1616
use fmt;
17-
use io::{Reader, Writer, Stream, Buffer, DEFAULT_BUF_SIZE, IoResult};
17+
use old_io::{Reader, Writer, Stream, Buffer, DEFAULT_BUF_SIZE, IoResult};
1818
use iter::{IteratorExt, ExactSizeIterator, repeat};
1919
use ops::Drop;
2020
use option::Option;
@@ -34,7 +34,7 @@ use vec::Vec;
3434
/// # Example
3535
///
3636
/// ```rust
37-
/// use std::io::{BufferedReader, File};
37+
/// use std::old_io::{BufferedReader, File};
3838
///
3939
/// let file = File::open(&Path::new("message.txt"));
4040
/// let mut reader = BufferedReader::new(file);
@@ -137,7 +137,7 @@ impl<R: Reader> Reader for BufferedReader<R> {
137137
/// # Example
138138
///
139139
/// ```rust
140-
/// use std::io::{BufferedWriter, File};
140+
/// use std::old_io::{BufferedWriter, File};
141141
///
142142
/// let file = File::create(&Path::new("message.txt")).unwrap();
143143
/// let mut writer = BufferedWriter::new(file);
@@ -324,7 +324,7 @@ impl<W: Reader> Reader for InternalBufferedWriter<W> {
324324
///
325325
/// ```rust
326326
/// # #![allow(unused_must_use)]
327-
/// use std::io::{BufferedStream, File};
327+
/// use std::old_io::{BufferedStream, File};
328328
///
329329
/// let file = File::open(&Path::new("message.txt"));
330330
/// let mut stream = BufferedStream::new(file);
@@ -437,13 +437,13 @@ mod test {
437437
pub struct NullStream;
438438

439439
impl Reader for NullStream {
440-
fn read(&mut self, _: &mut [u8]) -> io::IoResult<uint> {
441-
Err(io::standard_error(io::EndOfFile))
440+
fn read(&mut self, _: &mut [u8]) -> old_io::IoResult<uint> {
441+
Err(old_io::standard_error(old_io::EndOfFile))
442442
}
443443
}
444444

445445
impl Writer for NullStream {
446-
fn write(&mut self, _: &[u8]) -> io::IoResult<()> { Ok(()) }
446+
fn write(&mut self, _: &[u8]) -> old_io::IoResult<()> { Ok(()) }
447447
}
448448

449449
/// A dummy reader intended at testing short-reads propagation.
@@ -452,9 +452,9 @@ mod test {
452452
}
453453

454454
impl Reader for ShortReader {
455-
fn read(&mut self, _: &mut [u8]) -> io::IoResult<uint> {
455+
fn read(&mut self, _: &mut [u8]) -> old_io::IoResult<uint> {
456456
if self.lengths.is_empty() {
457-
Err(io::standard_error(io::EndOfFile))
457+
Err(old_io::standard_error(old_io::EndOfFile))
458458
} else {
459459
Ok(self.lengths.remove(0))
460460
}
@@ -555,13 +555,13 @@ mod test {
555555
fn test_buffered_stream() {
556556
struct S;
557557

558-
impl io::Writer for S {
559-
fn write(&mut self, _: &[u8]) -> io::IoResult<()> { Ok(()) }
558+
impl old_io::Writer for S {
559+
fn write(&mut self, _: &[u8]) -> old_io::IoResult<()> { Ok(()) }
560560
}
561561

562-
impl io::Reader for S {
563-
fn read(&mut self, _: &mut [u8]) -> io::IoResult<uint> {
564-
Err(io::standard_error(io::EndOfFile))
562+
impl old_io::Reader for S {
563+
fn read(&mut self, _: &mut [u8]) -> old_io::IoResult<uint> {
564+
Err(old_io::standard_error(old_io::EndOfFile))
565565
}
566566
}
567567

@@ -664,7 +664,7 @@ mod test {
664664

665665
impl Writer for FailFlushWriter {
666666
fn write(&mut self, _buf: &[u8]) -> IoResult<()> { Ok(()) }
667-
fn flush(&mut self) -> IoResult<()> { Err(io::standard_error(EndOfFile)) }
667+
fn flush(&mut self) -> IoResult<()> { Err(old_io::standard_error(EndOfFile)) }
668668
}
669669

670670
let writer = FailFlushWriter;

src/libstd/io/comm_adapters.rs renamed to src/libstd/old_io/comm_adapters.rs

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
use clone::Clone;
1212
use cmp;
1313
use sync::mpsc::{Sender, Receiver};
14-
use io;
14+
use old_io;
1515
use option::Option::{None, Some};
1616
use result::Result::{Ok, Err};
1717
use slice::{bytes, SliceExt};
@@ -24,7 +24,7 @@ use vec::Vec;
2424
///
2525
/// ```
2626
/// use std::sync::mpsc::channel;
27-
/// use std::io::ChanReader;
27+
/// use std::old_io::ChanReader;
2828
///
2929
/// let (tx, rx) = channel();
3030
/// # drop(tx);
@@ -70,7 +70,7 @@ impl Buffer for ChanReader {
7070
}
7171
}
7272
if self.closed {
73-
Err(io::standard_error(io::EndOfFile))
73+
Err(old_io::standard_error(old_io::EndOfFile))
7474
} else {
7575
Ok(&self.buf[self.pos..])
7676
}
@@ -102,7 +102,7 @@ impl Reader for ChanReader {
102102
}
103103
}
104104
if self.closed && num_read == 0 {
105-
Err(io::standard_error(io::EndOfFile))
105+
Err(old_io::standard_error(old_io::EndOfFile))
106106
} else {
107107
Ok(num_read)
108108
}
@@ -116,7 +116,7 @@ impl Reader for ChanReader {
116116
/// ```
117117
/// # #![allow(unused_must_use)]
118118
/// use std::sync::mpsc::channel;
119-
/// use std::io::ChanWriter;
119+
/// use std::old_io::ChanWriter;
120120
///
121121
/// let (tx, rx) = channel();
122122
/// # drop(rx);
@@ -144,8 +144,8 @@ impl Clone for ChanWriter {
144144
impl Writer for ChanWriter {
145145
fn write(&mut self, buf: &[u8]) -> IoResult<()> {
146146
self.tx.send(buf.to_vec()).map_err(|_| {
147-
io::IoError {
148-
kind: io::BrokenPipe,
147+
old_io::IoError {
148+
kind: old_io::BrokenPipe,
149149
desc: "Pipe closed",
150150
detail: None
151151
}
@@ -193,14 +193,14 @@ mod test {
193193

194194
match reader.read(buf.as_mut_slice()) {
195195
Ok(..) => panic!(),
196-
Err(e) => assert_eq!(e.kind, io::EndOfFile),
196+
Err(e) => assert_eq!(e.kind, old_io::EndOfFile),
197197
}
198198
assert_eq!(a, buf);
199199

200200
// Ensure it continues to panic in the same way.
201201
match reader.read(buf.as_mut_slice()) {
202202
Ok(..) => panic!(),
203-
Err(e) => assert_eq!(e.kind, io::EndOfFile),
203+
Err(e) => assert_eq!(e.kind, old_io::EndOfFile),
204204
}
205205
assert_eq!(a, buf);
206206
}
@@ -223,7 +223,7 @@ mod test {
223223
assert_eq!(Ok("how are you?".to_string()), reader.read_line());
224224
match reader.read_line() {
225225
Ok(..) => panic!(),
226-
Err(e) => assert_eq!(e.kind, io::EndOfFile),
226+
Err(e) => assert_eq!(e.kind, old_io::EndOfFile),
227227
}
228228
}
229229

@@ -242,7 +242,7 @@ mod test {
242242

243243
match writer.write_u8(1) {
244244
Ok(..) => panic!(),
245-
Err(e) => assert_eq!(e.kind, io::BrokenPipe),
245+
Err(e) => assert_eq!(e.kind, old_io::BrokenPipe),
246246
}
247247
}
248248
}

src/libstd/io/extensions.rs renamed to src/libstd/old_io/extensions.rs

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -15,8 +15,8 @@
1515
// FIXME: Not sure how this should be structured
1616
// FIXME: Iteration should probably be considered separately
1717

18-
use io::{IoError, IoResult, Reader};
19-
use io;
18+
use old_io::{IoError, IoResult, Reader};
19+
use old_io;
2020
use iter::Iterator;
2121
use num::Int;
2222
use ops::FnOnce;
@@ -59,7 +59,7 @@ impl<'r, R: Reader> Iterator for Bytes<'r, R> {
5959
fn next(&mut self) -> Option<IoResult<u8>> {
6060
match self.reader.read_byte() {
6161
Ok(x) => Some(Ok(x)),
62-
Err(IoError { kind: io::EndOfFile, .. }) => None,
62+
Err(IoError { kind: old_io::EndOfFile, .. }) => None,
6363
Err(e) => Some(Err(e))
6464
}
6565
}
@@ -179,14 +179,14 @@ pub fn u64_from_be_bytes(data: &[u8], start: uint, size: uint) -> u64 {
179179
mod test {
180180
use prelude::v1::*;
181181
use io;
182-
use io::{MemReader, BytesReader};
182+
use old_io::{MemReader, BytesReader};
183183

184184
struct InitialZeroByteReader {
185185
count: int,
186186
}
187187

188188
impl Reader for InitialZeroByteReader {
189-
fn read(&mut self, buf: &mut [u8]) -> io::IoResult<uint> {
189+
fn read(&mut self, buf: &mut [u8]) -> old_io::IoResult<uint> {
190190
if self.count == 0 {
191191
self.count = 1;
192192
Ok(0)
@@ -200,16 +200,16 @@ mod test {
200200
struct EofReader;
201201

202202
impl Reader for EofReader {
203-
fn read(&mut self, _: &mut [u8]) -> io::IoResult<uint> {
204-
Err(io::standard_error(io::EndOfFile))
203+
fn read(&mut self, _: &mut [u8]) -> old_io::IoResult<uint> {
204+
Err(old_io::standard_error(old_io::EndOfFile))
205205
}
206206
}
207207

208208
struct ErroringReader;
209209

210210
impl Reader for ErroringReader {
211-
fn read(&mut self, _: &mut [u8]) -> io::IoResult<uint> {
212-
Err(io::standard_error(io::InvalidInput))
211+
fn read(&mut self, _: &mut [u8]) -> old_io::IoResult<uint> {
212+
Err(old_io::standard_error(old_io::InvalidInput))
213213
}
214214
}
215215

@@ -218,7 +218,7 @@ mod test {
218218
}
219219

220220
impl Reader for PartialReader {
221-
fn read(&mut self, buf: &mut [u8]) -> io::IoResult<uint> {
221+
fn read(&mut self, buf: &mut [u8]) -> old_io::IoResult<uint> {
222222
if self.count == 0 {
223223
self.count = 1;
224224
buf[0] = 10;
@@ -237,13 +237,13 @@ mod test {
237237
}
238238

239239
impl Reader for ErroringLaterReader {
240-
fn read(&mut self, buf: &mut [u8]) -> io::IoResult<uint> {
240+
fn read(&mut self, buf: &mut [u8]) -> old_io::IoResult<uint> {
241241
if self.count == 0 {
242242
self.count = 1;
243243
buf[0] = 10;
244244
Ok(1)
245245
} else {
246-
Err(io::standard_error(io::InvalidInput))
246+
Err(old_io::standard_error(old_io::InvalidInput))
247247
}
248248
}
249249
}
@@ -253,7 +253,7 @@ mod test {
253253
}
254254

255255
impl Reader for ThreeChunkReader {
256-
fn read(&mut self, buf: &mut [u8]) -> io::IoResult<uint> {
256+
fn read(&mut self, buf: &mut [u8]) -> old_io::IoResult<uint> {
257257
if self.count == 0 {
258258
self.count = 1;
259259
buf[0] = 10;
@@ -265,7 +265,7 @@ mod test {
265265
buf[1] = 13;
266266
Ok(2)
267267
} else {
268-
Err(io::standard_error(io::EndOfFile))
268+
Err(old_io::standard_error(old_io::EndOfFile))
269269
}
270270
}
271271
}

0 commit comments

Comments
 (0)