Skip to content

Commit f606b60

Browse files
Christian Stefanescuseanmonstar
Christian Stefanescu
authored andcommitted
fix(rustup): update io import, Writer::write
Make it build with the latest rust-nightly (2015-01-27) Renamed io import to old_io. Renamed Writer::write to Writer::write_all
1 parent 537d691 commit f606b60

18 files changed

+81
-81
lines changed

benches/client.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ extern crate hyper;
44
extern crate test;
55

66
use std::fmt;
7-
use std::io::net::ip::Ipv4Addr;
7+
use std::old_io::net::ip::Ipv4Addr;
88
use hyper::server::{Request, Response, Server};
99
use hyper::header::Headers;
1010
use hyper::Client;
@@ -26,7 +26,7 @@ macro_rules! try_return(
2626
fn handle(_r: Request, res: Response) {
2727
static BODY: &'static [u8] = b"Benchmarking hyper vs others!";
2828
let mut res = try_return!(res.start());
29-
try_return!(res.write(BODY));
29+
try_return!(res.write_all(BODY));
3030
try_return!(res.end());
3131
}
3232

benches/client_mock_tcp.rs

+3-3
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,8 @@ extern crate hyper;
44
extern crate test;
55

66
use std::fmt;
7-
use std::io::{IoResult, MemReader};
8-
use std::io::net::ip::SocketAddr;
7+
use std::old_io::{IoResult, MemReader};
8+
use std::old_io::net::ip::SocketAddr;
99

1010
use hyper::net;
1111

@@ -40,7 +40,7 @@ impl Reader for MockStream {
4040
}
4141

4242
impl Writer for MockStream {
43-
fn write(&mut self, _msg: &[u8]) -> IoResult<()> {
43+
fn write_all(&mut self, _msg: &[u8]) -> IoResult<()> {
4444
// we're mocking, what do we care.
4545
Ok(())
4646
}

benches/server.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ extern crate hyper;
33
extern crate test;
44

55
use test::Bencher;
6-
use std::io::net::ip::Ipv4Addr;
6+
use std::old_io::net::ip::Ipv4Addr;
77

88
use hyper::method::Method::Get;
99
use hyper::server::{Request, Response};
@@ -17,7 +17,7 @@ fn request(url: hyper::Url) {
1717

1818
fn hyper_handle(_: Request, res: Response) {
1919
let mut res = res.start().unwrap();
20-
res.write(PHRASE).unwrap();
20+
res.write_all(PHRASE).unwrap();
2121
res.end().unwrap();
2222
}
2323

examples/client.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,8 @@
22
extern crate hyper;
33

44
use std::os;
5-
use std::io::stdout;
6-
use std::io::util::copy;
5+
use std::old_io::stdout;
6+
use std::old_io::util::copy;
77

88
use hyper::Client;
99

examples/hello.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,14 @@
11
#![allow(unstable)]
22
extern crate hyper;
33

4-
use std::io::net::ip::Ipv4Addr;
4+
use std::old_io::net::ip::Ipv4Addr;
55
use hyper::server::{Request, Response};
66

77
static PHRASE: &'static [u8] = b"Hello World!";
88

99
fn hello(_: Request, res: Response) {
1010
let mut res = res.start().unwrap();
11-
res.write(PHRASE).unwrap();
11+
res.write_all(PHRASE).unwrap();
1212
res.end().unwrap();
1313
}
1414

examples/server.rs

+3-3
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,8 @@
22
extern crate hyper;
33
#[macro_use] extern crate log;
44

5-
use std::io::util::copy;
6-
use std::io::net::ip::Ipv4Addr;
5+
use std::old_io::util::copy;
6+
use std::old_io::net::ip::Ipv4Addr;
77

88
use hyper::{Get, Post};
99
use hyper::header::ContentLength;
@@ -27,7 +27,7 @@ fn echo(mut req: Request, mut res: Response) {
2727

2828
res.headers_mut().set(ContentLength(out.len() as u64));
2929
let mut res = try_return!(res.start());
30-
try_return!(res.write(out));
30+
try_return!(res.write_all(out));
3131
try_return!(res.end());
3232
return;
3333
},

src/client/mod.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -18,8 +18,8 @@
1818
//! to the `status`, the `headers`, and the response body via the `Writer`
1919
//! trait.
2020
use std::default::Default;
21-
use std::io::IoResult;
22-
use std::io::util::copy;
21+
use std::old_io::IoResult;
22+
use std::old_io::util::copy;
2323
use std::iter::Extend;
2424

2525
use url::UrlParser;

src/client/request.rs

+3-3
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
//! Client Requests
2-
use std::io::{BufferedWriter, IoResult};
2+
use std::old_io::{BufferedWriter, IoResult};
33

44
use url::Url;
55

@@ -157,8 +157,8 @@ impl Request<Streaming> {
157157

158158
impl Writer for Request<Streaming> {
159159
#[inline]
160-
fn write(&mut self, msg: &[u8]) -> IoResult<()> {
161-
self.body.write(msg)
160+
fn write_all(&mut self, msg: &[u8]) -> IoResult<()> {
161+
self.body.write_all(msg)
162162
}
163163

164164
#[inline]

src/client/response.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
//! Client Responses
22
use std::num::FromPrimitive;
3-
use std::io::{BufferedReader, IoResult};
3+
use std::old_io::{BufferedReader, IoResult};
44

55
use header;
66
use header::{ContentLength, TransferEncoding};
@@ -97,7 +97,7 @@ impl Reader for Response {
9797
mod tests {
9898
use std::borrow::Cow::Borrowed;
9999
use std::boxed::BoxAny;
100-
use std::io::BufferedReader;
100+
use std::old_io::BufferedReader;
101101

102102
use header::Headers;
103103
use header::TransferEncoding;

src/header/common/authorization.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -141,7 +141,7 @@ impl FromStr for Basic {
141141

142142
#[cfg(test)]
143143
mod tests {
144-
use std::io::MemReader;
144+
use std::old_io::MemReader;
145145
use super::{Authorization, Basic};
146146
use super::super::super::{Headers};
147147

src/header/mod.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -505,7 +505,7 @@ impl<'a, H: HeaderFormat> fmt::Debug for HeaderFormatter<'a, H> {
505505

506506
#[cfg(test)]
507507
mod tests {
508-
use std::io::MemReader;
508+
use std::old_io::MemReader;
509509
use std::fmt;
510510
use std::borrow::Cow::Borrowed;
511511
use std::hash::{SipHasher, hash};

src/http.rs

+32-32
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
use std::borrow::Cow::{Borrowed, Owned};
33
use std::borrow::IntoCow;
44
use std::cmp::min;
5-
use std::io::{self, Reader, IoResult, BufWriter};
5+
use std::old_io::{self, Reader, IoResult, BufWriter};
66
use std::num::from_u16;
77
use std::str::{self, FromStr};
88
use std::string::CowString;
@@ -72,7 +72,7 @@ impl<R: Reader> Reader for HttpReader<R> {
7272
SizedReader(ref mut body, ref mut remaining) => {
7373
debug!("Sized read, remaining={:?}", remaining);
7474
if *remaining == 0 {
75-
Err(io::standard_error(io::EndOfFile))
75+
Err(old_io::standard_error(old_io::EndOfFile))
7676
} else {
7777
let num = try!(body.read(buf)) as u64;
7878
if num > *remaining {
@@ -98,7 +98,7 @@ impl<R: Reader> Reader for HttpReader<R> {
9898
// if the 0 digit was missing from the stream, it would
9999
// be an InvalidInput error instead.
100100
debug!("end of chunked");
101-
return Err(io::standard_error(io::EndOfFile));
101+
return Err(old_io::standard_error(old_io::EndOfFile));
102102
}
103103

104104
let to_read = min(rem as usize, buf.len());
@@ -116,7 +116,7 @@ impl<R: Reader> Reader for HttpReader<R> {
116116
EofReader(ref mut body) => {
117117
body.read(buf)
118118
},
119-
EmptyReader(_) => Err(io::standard_error(io::EndOfFile))
119+
EmptyReader(_) => Err(old_io::standard_error(old_io::EndOfFile))
120120
}
121121
}
122122
}
@@ -125,7 +125,7 @@ fn eat<R: Reader>(rdr: &mut R, bytes: &[u8]) -> IoResult<()> {
125125
for &b in bytes.iter() {
126126
match try!(rdr.read_byte()) {
127127
byte if byte == b => (),
128-
_ => return Err(io::standard_error(io::InvalidInput))
128+
_ => return Err(old_io::standard_error(old_io::InvalidInput))
129129
}
130130
}
131131
Ok(())
@@ -154,7 +154,7 @@ fn read_chunk_size<R: Reader>(rdr: &mut R) -> IoResult<u64> {
154154
CR => {
155155
match try!(rdr.read_byte()) {
156156
LF => break,
157-
_ => return Err(io::standard_error(io::InvalidInput))
157+
_ => return Err(old_io::standard_error(old_io::InvalidInput))
158158
}
159159
},
160160
// If we weren't in the extension yet, the ";" signals its start
@@ -178,7 +178,7 @@ fn read_chunk_size<R: Reader>(rdr: &mut R) -> IoResult<u64> {
178178
// Finally, if we aren't in the extension and we're reading any
179179
// other octet, the chunk size line is invalid!
180180
_ => {
181-
return Err(io::standard_error(io::InvalidInput));
181+
return Err(old_io::standard_error(old_io::InvalidInput));
182182
}
183183
}
184184
}
@@ -239,47 +239,47 @@ impl<W: Writer> HttpWriter<W> {
239239

240240
/// Ends the HttpWriter, and returns the underlying Writer.
241241
///
242-
/// A final `write()` is called with an empty message, and then flushed.
242+
/// A final `write_all()` is called with an empty message, and then flushed.
243243
/// The ChunkedWriter variant will use this to write the 0-sized last-chunk.
244244
#[inline]
245245
pub fn end(mut self) -> IoResult<W> {
246-
try!(self.write(&[]));
246+
try!(self.write_all(&[]));
247247
try!(self.flush());
248248
Ok(self.unwrap())
249249
}
250250
}
251251

252252
impl<W: Writer> Writer for HttpWriter<W> {
253253
#[inline]
254-
fn write(&mut self, msg: &[u8]) -> IoResult<()> {
254+
fn write_all(&mut self, msg: &[u8]) -> IoResult<()> {
255255
match *self {
256-
ThroughWriter(ref mut w) => w.write(msg),
256+
ThroughWriter(ref mut w) => w.write_all(msg),
257257
ChunkedWriter(ref mut w) => {
258258
let chunk_size = msg.len();
259259
debug!("chunked write, size = {:?}", chunk_size);
260260
try!(write!(w, "{:X}{}", chunk_size, LINE_ENDING));
261-
try!(w.write(msg));
261+
try!(w.write_all(msg));
262262
w.write_str(LINE_ENDING)
263263
},
264264
SizedWriter(ref mut w, ref mut remaining) => {
265265
let len = msg.len() as u64;
266266
if len > *remaining {
267267
let len = *remaining;
268268
*remaining = 0;
269-
try!(w.write(&msg[..len as usize]));
270-
Err(io::standard_error(io::ShortWrite(len as usize)))
269+
try!(w.write_all(&msg[..len as usize]));
270+
Err(old_io::standard_error(old_io::ShortWrite(len as usize)))
271271
} else {
272272
*remaining -= len;
273-
w.write(msg)
273+
w.write_all(msg)
274274
}
275275
},
276276
EmptyWriter(..) => {
277277
let bytes = msg.len();
278278
if bytes == 0 {
279279
Ok(())
280280
} else {
281-
Err(io::IoError {
282-
kind: io::ShortWrite(bytes),
281+
Err(old_io::IoError {
282+
kind: old_io::ShortWrite(bytes),
283283
desc: "EmptyWriter cannot write any bytes",
284284
detail: Some("Cannot include a body with this kind of message".to_string())
285285
})
@@ -347,7 +347,7 @@ pub fn is_token(b: u8) -> bool {
347347
///
348348
/// The remaining contents of `buf` are left untouched.
349349
fn read_token_until_space<R: Reader>(stream: &mut R, buf: &mut [u8]) -> HttpResult<bool> {
350-
use std::io::BufWriter;
350+
use std::old_io::BufWriter;
351351
let mut bufwrt = BufWriter::new(buf);
352352

353353
loop {
@@ -697,7 +697,7 @@ fn expect(r: IoResult<u8>, expected: u8) -> HttpResult<()> {
697697

698698
#[cfg(test)]
699699
mod tests {
700-
use std::io::{self, MemReader, MemWriter, IoResult};
700+
use std::old_io::{self, MemReader, MemWriter, IoResult};
701701
use std::borrow::Cow::{Borrowed, Owned};
702702
use test::Bencher;
703703
use uri::RequestUri;
@@ -800,8 +800,8 @@ mod tests {
800800
fn test_write_chunked() {
801801
use std::str::from_utf8;
802802
let mut w = super::HttpWriter::ChunkedWriter(MemWriter::new());
803-
w.write(b"foo bar").unwrap();
804-
w.write(b"baz quux herp").unwrap();
803+
w.write_all(b"foo bar").unwrap();
804+
w.write_all(b"baz quux herp").unwrap();
805805
let buf = w.end().unwrap().into_inner();
806806
let s = from_utf8(buf.as_slice()).unwrap();
807807
assert_eq!(s, "7\r\nfoo bar\r\nD\r\nbaz quux herp\r\n0\r\n\r\n");
@@ -811,8 +811,8 @@ mod tests {
811811
fn test_write_sized() {
812812
use std::str::from_utf8;
813813
let mut w = super::HttpWriter::SizedWriter(MemWriter::new(), 8);
814-
w.write(b"foo bar").unwrap();
815-
assert_eq!(w.write(b"baz"), Err(io::standard_error(io::ShortWrite(1))));
814+
w.write_all(b"foo bar").unwrap();
815+
assert_eq!(w.write_all(b"baz"), Err(old_io::standard_error(old_io::ShortWrite(1))));
816816

817817
let buf = w.end().unwrap().into_inner();
818818
let s = from_utf8(buf.as_slice()).unwrap();
@@ -834,13 +834,13 @@ mod tests {
834834
read("Ff\r\n", Ok(255));
835835
read("Ff \r\n", Ok(255));
836836
// Missing LF or CRLF
837-
read("F\rF", Err(io::standard_error(io::InvalidInput)));
838-
read("F", Err(io::standard_error(io::EndOfFile)));
837+
read("F\rF", Err(old_io::standard_error(old_io::InvalidInput)));
838+
read("F", Err(old_io::standard_error(old_io::EndOfFile)));
839839
// Invalid hex digit
840-
read("X\r\n", Err(io::standard_error(io::InvalidInput)));
841-
read("1X\r\n", Err(io::standard_error(io::InvalidInput)));
842-
read("-\r\n", Err(io::standard_error(io::InvalidInput)));
843-
read("-1\r\n", Err(io::standard_error(io::InvalidInput)));
840+
read("X\r\n", Err(old_io::standard_error(old_io::InvalidInput)));
841+
read("1X\r\n", Err(old_io::standard_error(old_io::InvalidInput)));
842+
read("-\r\n", Err(old_io::standard_error(old_io::InvalidInput)));
843+
read("-1\r\n", Err(old_io::standard_error(old_io::InvalidInput)));
844844
// Acceptable (if not fully valid) extensions do not influence the size
845845
read("1;extension\r\n", Ok(1));
846846
read("a;ext name=value\r\n", Ok(10));
@@ -851,9 +851,9 @@ mod tests {
851851
read("3 ;\r\n", Ok(3));
852852
read("3 ; \r\n", Ok(3));
853853
// Invalid extensions cause an error
854-
read("1 invalid extension\r\n", Err(io::standard_error(io::InvalidInput)));
855-
read("1 A\r\n", Err(io::standard_error(io::InvalidInput)));
856-
read("1;no CRLF", Err(io::standard_error(io::EndOfFile)));
854+
read("1 invalid extension\r\n", Err(old_io::standard_error(old_io::InvalidInput)));
855+
read("1 A\r\n", Err(old_io::standard_error(old_io::InvalidInput)));
856+
read("1;no CRLF", Err(old_io::standard_error(old_io::EndOfFile)));
857857
}
858858

859859
#[bench]

src/lib.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -136,7 +136,7 @@ extern crate cookie;
136136
extern crate mucell;
137137
extern crate unicase;
138138

139-
pub use std::io::net::ip::{SocketAddr, IpAddr, Ipv4Addr, Ipv6Addr, Port};
139+
pub use std::old_io::net::ip::{SocketAddr, IpAddr, Ipv4Addr, Ipv6Addr, Port};
140140
pub use mimewrapper::mime;
141141
pub use url::Url;
142142
pub use client::Client;
@@ -146,7 +146,7 @@ pub use server::Server;
146146

147147
use std::error::{Error, FromError};
148148
use std::fmt;
149-
use std::io::IoError;
149+
use std::old_io::IoError;
150150

151151
use self::HttpError::{HttpMethodError, HttpUriError, HttpVersionError,
152152
HttpHeaderError, HttpStatusError, HttpIoError};

0 commit comments

Comments
 (0)