Skip to content

Commit

Permalink
fix(rustup): adapt to current rustc
Browse files Browse the repository at this point in the history
Closes #381.
  • Loading branch information
adrianheine committed Mar 19, 2015
1 parent 7469e62 commit 1f0bc95
Show file tree
Hide file tree
Showing 7 changed files with 14 additions and 16 deletions.
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ Hello World Server:
extern crate hyper;

use std::io::Write;
use std::net::IpAddr;
use std::net::Ipv4Addr;

use hyper::Server;
use hyper::server::Request;
Expand All @@ -42,7 +42,7 @@ fn hello(_: Request, mut res: Response<Fresh>) {
}

fn main() {
Server::http(hello).listen(IpAddr::new_v4(127, 0, 0, 1), 3000).unwrap();
Server::http(hello).listen(Ipv4Addr::new(127, 0, 0, 1), 3000).unwrap();
}
```

Expand Down
4 changes: 2 additions & 2 deletions benches/server.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ extern crate test;

use test::Bencher;
use std::io::{Read, Write};
use std::net::IpAddr;
use std::net::Ipv4Addr;

use hyper::method::Method::Get;
use hyper::server::{Request, Response};
Expand All @@ -27,7 +27,7 @@ fn hyper_handle(_: Request, res: Response) {
#[bench]
fn bench_hyper(b: &mut Bencher) {
let server = hyper::Server::http(hyper_handle);
let mut listener = server.listen(IpAddr::new_v4(127, 0, 0, 1), 0).unwrap();
let mut listener = server.listen(Ipv4Addr::new(127, 0, 0, 1), 0).unwrap();

let url = hyper::Url::parse(&*format!("http://{}", listener.socket)).unwrap();
b.iter(|| request(url.clone()));
Expand Down
5 changes: 2 additions & 3 deletions examples/hello.rs
Original file line number Diff line number Diff line change
@@ -1,10 +1,9 @@
#![deny(warnings)]
#![feature(net)]
extern crate hyper;
extern crate env_logger;

use std::io::Write;
use std::net::IpAddr;
use std::net::Ipv4Addr;
use hyper::server::{Request, Response};

static PHRASE: &'static [u8] = b"Hello World!";
Expand All @@ -18,6 +17,6 @@ fn hello(_: Request, res: Response) {
fn main() {
env_logger::init().unwrap();
let _listening = hyper::Server::http(hello)
.listen(IpAddr::new_v4(127, 0, 0, 1), 3000).unwrap();
.listen(Ipv4Addr::new(127, 0, 0, 1), 3000).unwrap();
println!("Listening on http://127.0.0.1:3000");
}
5 changes: 2 additions & 3 deletions examples/server.rs
Original file line number Diff line number Diff line change
@@ -1,10 +1,9 @@
#![deny(warnings)]
#![feature(net)]
extern crate hyper;
extern crate env_logger;

use std::io::{Write, copy};
use std::net::IpAddr;
use std::net::Ipv4Addr;

use hyper::{Get, Post};
use hyper::header::ContentLength;
Expand Down Expand Up @@ -53,6 +52,6 @@ fn echo(mut req: Request, mut res: Response) {
fn main() {
env_logger::init().unwrap();
let server = Server::http(echo);
let _guard = server.listen(IpAddr::new_v4(127, 0, 0, 1), 1337).unwrap();
let _guard = server.listen(Ipv4Addr::new(127, 0, 0, 1), 1337).unwrap();
println!("Listening on http://127.0.0.1:1337");
}
2 changes: 1 addition & 1 deletion src/lib.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#![feature(core, collections, io, net,
#![feature(core, collections, io,
std_misc, box_syntax, unsafe_destructor)]
#![deny(missing_docs)]
#![cfg_attr(test, deny(warnings))]
Expand Down
4 changes: 2 additions & 2 deletions src/net.rs
Original file line number Diff line number Diff line change
Expand Up @@ -215,8 +215,8 @@ impl NetworkListener for HttpListener {
#[inline]
fn socket_addr(&mut self) -> io::Result<SocketAddr> {
match *self {
HttpListener::Http(ref mut tcp) => tcp.socket_addr(),
HttpListener::Https(ref mut tcp, _) => tcp.socket_addr(),
HttpListener::Http(ref mut tcp) => tcp.local_addr(),
HttpListener::Https(ref mut tcp, _) => tcp.local_addr(),
}
}
}
Expand Down
6 changes: 3 additions & 3 deletions src/server/mod.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
//! HTTP Server
use std::io::{BufReader, BufWriter, Write};
use std::marker::PhantomData;
use std::net::{IpAddr, SocketAddr};
use std::net::{Ipv4Addr, SocketAddr};
use std::path::Path;
use std::thread::{self, JoinGuard};

Expand Down Expand Up @@ -76,7 +76,7 @@ impl<'a, H: Handler + 'static> Server<'a, H, HttpListener> {

impl<'a, H: Handler + 'static> Server<'a, H, HttpListener> {
/// Binds to a socket, and starts handling connections using a task pool.
pub fn listen_threads(self, ip: IpAddr, port: u16, threads: usize) -> HttpResult<Listening> {
pub fn listen_threads(self, ip: Ipv4Addr, port: u16, threads: usize) -> HttpResult<Listening> {
let addr = &(ip, port);
let listener = try!(match self.ssl {
Some((cert, key)) => HttpListener::https(addr, cert, key),
Expand All @@ -86,7 +86,7 @@ impl<'a, H: Handler + 'static> Server<'a, H, HttpListener> {
}

/// Binds to a socket and starts handling connections.
pub fn listen(self, ip: IpAddr, port: u16) -> HttpResult<Listening> {
pub fn listen(self, ip: Ipv4Addr, port: u16) -> HttpResult<Listening> {
self.listen_threads(ip, port, num_cpus::get() * 5 / 4)
}
}
Expand Down

0 comments on commit 1f0bc95

Please sign in to comment.