fix(rustup): update to newest fmt trait names and slice syntax
This commit is contained in:
@@ -3,7 +3,7 @@ extern crate hyper;
|
||||
|
||||
extern crate test;
|
||||
|
||||
use std::fmt::{self, Show};
|
||||
use std::fmt;
|
||||
use std::io::net::ip::Ipv4Addr;
|
||||
use hyper::server::{Request, Response, Server};
|
||||
use hyper::header::Headers;
|
||||
@@ -44,7 +44,7 @@ impl hyper::header::Header for Foo {
|
||||
|
||||
impl hyper::header::HeaderFormat for Foo {
|
||||
fn fmt_header(&self, fmt: &mut fmt::Formatter) -> fmt::Result {
|
||||
"Bar".fmt(fmt)
|
||||
fmt.write_str("Bar")
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -3,7 +3,7 @@ extern crate hyper;
|
||||
|
||||
extern crate test;
|
||||
|
||||
use std::fmt::{self, Show};
|
||||
use std::fmt;
|
||||
use std::io::{IoResult, MemReader};
|
||||
use std::io::net::ip::SocketAddr;
|
||||
|
||||
@@ -60,7 +60,7 @@ impl hyper::header::Header for Foo {
|
||||
|
||||
impl hyper::header::HeaderFormat for Foo {
|
||||
fn fmt_header(&self, fmt: &mut fmt::Formatter) -> fmt::Result {
|
||||
"Bar".fmt(fmt)
|
||||
fmt.write_str("Bar")
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -25,7 +25,7 @@ use mime;
|
||||
/// qitem(Mime(Text, Html, vec![])),
|
||||
/// qitem(Mime(Text, Xml, vec![])) ]));
|
||||
/// ```
|
||||
#[derive(Clone, PartialEq, Show)]
|
||||
#[derive(Clone, PartialEq, Debug)]
|
||||
pub struct Accept(pub Vec<header::QualityItem<mime::Mime>>);
|
||||
|
||||
deref!(Accept => Vec<header::QualityItem<mime::Mime>>);
|
||||
|
||||
@@ -4,7 +4,7 @@ use header::{self, Encoding, QualityItem};
|
||||
///
|
||||
/// The `Accept-Encoding` header can be used by clients to indicate what
|
||||
/// response encodings they accept.
|
||||
#[derive(Clone, PartialEq, Show)]
|
||||
#[derive(Clone, PartialEq, Debug)]
|
||||
pub struct AcceptEncoding(pub Vec<QualityItem<Encoding>>);
|
||||
|
||||
impl_list_header!(AcceptEncoding,
|
||||
|
||||
@@ -6,7 +6,7 @@ use header::parsing::{from_comma_delimited, fmt_comma_delimited};
|
||||
/// The `Allow` header.
|
||||
/// See also https://tools.ietf.org/html/rfc7231#section-7.4.1
|
||||
|
||||
#[derive(Clone, PartialEq, Show)]
|
||||
#[derive(Clone, PartialEq, Debug)]
|
||||
pub struct Allow(pub Vec<Method>);
|
||||
|
||||
deref!(Allow => Vec<Method>);
|
||||
|
||||
@@ -5,7 +5,7 @@ use serialize::base64::{ToBase64, FromBase64, Standard, Config, Newline};
|
||||
use header::{Header, HeaderFormat};
|
||||
|
||||
/// The `Authorization` header field.
|
||||
#[derive(Clone, PartialEq, Show)]
|
||||
#[derive(Clone, PartialEq, Debug)]
|
||||
pub struct Authorization<S: Scheme>(pub S);
|
||||
|
||||
impl<S: Scheme> Deref for Authorization<S> {
|
||||
@@ -75,7 +75,7 @@ impl Scheme for String {
|
||||
}
|
||||
|
||||
/// Credential holder for Basic Authentication
|
||||
#[derive(Clone, PartialEq, Show)]
|
||||
#[derive(Clone, PartialEq, Debug)]
|
||||
pub struct Basic {
|
||||
/// The username as a possibly empty string
|
||||
pub username: String,
|
||||
@@ -90,7 +90,7 @@ impl Scheme for Basic {
|
||||
}
|
||||
|
||||
fn fmt_scheme(&self, f: &mut fmt::Formatter) -> fmt::Result {
|
||||
//FIXME: serialize::base64 could use some Show implementation, so
|
||||
//FIXME: serialize::base64 could use some Debug implementation, so
|
||||
//that we don't have to allocate a new string here just to write it
|
||||
//to the formatter.
|
||||
let mut text = self.username.clone();
|
||||
|
||||
@@ -4,7 +4,7 @@ use header::{Header, HeaderFormat};
|
||||
use header::parsing::{from_one_comma_delimited, fmt_comma_delimited};
|
||||
|
||||
/// The Cache-Control header.
|
||||
#[derive(PartialEq, Clone, Show)]
|
||||
#[derive(PartialEq, Clone, Debug)]
|
||||
pub struct CacheControl(pub Vec<CacheDirective>);
|
||||
|
||||
deref!(CacheControl => Vec<CacheDirective>);
|
||||
@@ -34,7 +34,7 @@ impl HeaderFormat for CacheControl {
|
||||
}
|
||||
|
||||
/// CacheControl contains a list of these directives.
|
||||
#[derive(PartialEq, Clone, Show)]
|
||||
#[derive(PartialEq, Clone, Debug)]
|
||||
pub enum CacheDirective {
|
||||
/// "no-cache"
|
||||
NoCache,
|
||||
@@ -69,10 +69,10 @@ pub enum CacheDirective {
|
||||
Extension(String, Option<String>)
|
||||
}
|
||||
|
||||
impl fmt::String for CacheDirective {
|
||||
impl fmt::Display for CacheDirective {
|
||||
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
|
||||
use self::CacheDirective::*;
|
||||
fmt::String::fmt(match *self {
|
||||
fmt::Display::fmt(match *self {
|
||||
NoCache => "no-cache",
|
||||
NoStore => "no-store",
|
||||
NoTransform => "no-transform",
|
||||
|
||||
@@ -6,13 +6,13 @@ use header::parsing::{from_comma_delimited, fmt_comma_delimited};
|
||||
pub use self::ConnectionOption::{KeepAlive, Close, ConnectionHeader};
|
||||
|
||||
/// The `Connection` header.
|
||||
#[derive(Clone, PartialEq, Show)]
|
||||
#[derive(Clone, PartialEq, Debug)]
|
||||
pub struct Connection(pub Vec<ConnectionOption>);
|
||||
|
||||
deref!(Connection => Vec<ConnectionOption>);
|
||||
|
||||
/// Values that can be in the `Connection` header.
|
||||
#[derive(Clone, PartialEq, Show)]
|
||||
#[derive(Clone, PartialEq, Debug)]
|
||||
pub enum ConnectionOption {
|
||||
/// The `keep-alive` connection value.
|
||||
KeepAlive,
|
||||
@@ -39,7 +39,7 @@ impl FromStr for ConnectionOption {
|
||||
}
|
||||
}
|
||||
|
||||
impl fmt::String for ConnectionOption {
|
||||
impl fmt::Display for ConnectionOption {
|
||||
fn fmt(&self, fmt: &mut fmt::Formatter) -> fmt::Result {
|
||||
write!(fmt, "{}", match *self {
|
||||
KeepAlive => "keep-alive",
|
||||
|
||||
@@ -6,7 +6,7 @@ use header::parsing::from_one_raw_str;
|
||||
/// The `Content-Length` header.
|
||||
///
|
||||
/// Simply a wrapper around a `usize`.
|
||||
#[derive(Copy, Clone, PartialEq, Show)]
|
||||
#[derive(Copy, Clone, PartialEq, Debug)]
|
||||
pub struct ContentLength(pub u64);
|
||||
|
||||
deref!(ContentLength => u64);
|
||||
@@ -23,7 +23,7 @@ impl Header for ContentLength {
|
||||
|
||||
impl HeaderFormat for ContentLength {
|
||||
fn fmt_header(&self, fmt: &mut fmt::Formatter) -> fmt::Result {
|
||||
fmt::String::fmt(&self.0, fmt)
|
||||
fmt::Display::fmt(&self.0, fmt)
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -7,7 +7,7 @@ use mime::Mime;
|
||||
///
|
||||
/// Used to describe the MIME type of message body. Can be used with both
|
||||
/// requests and responses.
|
||||
#[derive(Clone, PartialEq, Show)]
|
||||
#[derive(Clone, PartialEq, Debug)]
|
||||
pub struct ContentType(pub Mime);
|
||||
|
||||
deref!(ContentType => Mime);
|
||||
@@ -24,7 +24,7 @@ impl Header for ContentType {
|
||||
|
||||
impl HeaderFormat for ContentType {
|
||||
fn fmt_header(&self, fmt: &mut fmt::Formatter) -> fmt::Result {
|
||||
fmt::String::fmt(&self.0, fmt)
|
||||
fmt::Display::fmt(&self.0, fmt)
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -13,7 +13,7 @@ use cookie::CookieJar;
|
||||
///
|
||||
/// > When the user agent generates an HTTP request, the user agent MUST NOT
|
||||
/// > attach more than one Cookie header field.
|
||||
#[derive(Clone, PartialEq, Show)]
|
||||
#[derive(Clone, PartialEq, Debug)]
|
||||
pub struct Cookies(pub Vec<Cookie>);
|
||||
|
||||
deref!(Cookies => Vec<Cookie>);
|
||||
@@ -53,7 +53,7 @@ impl HeaderFormat for Cookies {
|
||||
let last = cookies.len() - 1;
|
||||
for (i, cookie) in cookies.iter().enumerate() {
|
||||
try!(write!(fmt, "{}", cookie.pair()));
|
||||
if i < last {
|
||||
if i < last {
|
||||
try!(fmt.write_str("; "));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -7,7 +7,7 @@ use header::parsing::tm_from_str;
|
||||
|
||||
// Egh, replace as soon as something better than time::Tm exists.
|
||||
/// The `Date` header field.
|
||||
#[derive(Copy, PartialEq, Clone, Show)]
|
||||
#[derive(Copy, PartialEq, Clone, Debug)]
|
||||
pub struct Date(pub Tm);
|
||||
|
||||
deref!(Date => Tm);
|
||||
@@ -30,7 +30,7 @@ impl HeaderFormat for Date {
|
||||
0 => tm,
|
||||
_ => tm.to_utc(),
|
||||
};
|
||||
fmt::String::fmt(&tm.rfc822(), fmt)
|
||||
fmt::Display::fmt(&tm.rfc822(), fmt)
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -8,7 +8,7 @@ use header::parsing::from_one_raw_str;
|
||||
/// Preceding the first double quote is an optional weakness indicator,
|
||||
/// which always looks like this: W/
|
||||
/// See also: https://tools.ietf.org/html/rfc7232#section-2.3
|
||||
#[derive(Clone, PartialEq, Show)]
|
||||
#[derive(Clone, PartialEq, Debug)]
|
||||
pub struct Etag {
|
||||
/// Weakness indicator for the tag
|
||||
pub weak: bool,
|
||||
|
||||
@@ -6,7 +6,7 @@ use header::parsing::from_one_raw_str;
|
||||
use header::parsing::tm_from_str;
|
||||
|
||||
/// The `Expires` header field.
|
||||
#[derive(Copy, PartialEq, Clone, Show)]
|
||||
#[derive(Copy, PartialEq, Clone, Debug)]
|
||||
pub struct Expires(pub Tm);
|
||||
|
||||
deref!(Expires => Tm);
|
||||
@@ -29,7 +29,7 @@ impl HeaderFormat for Expires {
|
||||
0 => tm,
|
||||
_ => tm.to_utc(),
|
||||
};
|
||||
fmt::String::fmt(&tm.rfc822(), fmt)
|
||||
fmt::Display::fmt(&tm.rfc822(), fmt)
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -10,7 +10,7 @@ use header::parsing::from_one_raw_str;
|
||||
///
|
||||
/// Currently is just a String, but it should probably become a better type,
|
||||
/// like url::Host or something.
|
||||
#[derive(Clone, PartialEq, Show)]
|
||||
#[derive(Clone, PartialEq, Debug)]
|
||||
pub struct Host {
|
||||
/// The hostname, such a example.domain.
|
||||
pub hostname: String,
|
||||
@@ -46,7 +46,7 @@ impl Header for Host {
|
||||
};
|
||||
|
||||
let port = match idx {
|
||||
Some(idx) => s[].slice_from(idx + 1).parse(),
|
||||
Some(idx) => s[idx + 1..].parse(),
|
||||
None => None
|
||||
};
|
||||
|
||||
|
||||
@@ -6,7 +6,7 @@ use header::parsing::from_one_raw_str;
|
||||
use header::parsing::tm_from_str;
|
||||
|
||||
/// The `If-Modified-Since` header field.
|
||||
#[derive(Copy, PartialEq, Clone, Show)]
|
||||
#[derive(Copy, PartialEq, Clone, Debug)]
|
||||
pub struct IfModifiedSince(pub Tm);
|
||||
|
||||
deref!(IfModifiedSince => Tm);
|
||||
@@ -29,7 +29,7 @@ impl HeaderFormat for IfModifiedSince {
|
||||
0 => tm,
|
||||
_ => tm.to_utc(),
|
||||
};
|
||||
fmt::String::fmt(&tm.rfc822(), fmt)
|
||||
fmt::Display::fmt(&tm.rfc822(), fmt)
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -6,7 +6,7 @@ use header::parsing::from_one_raw_str;
|
||||
use header::parsing::tm_from_str;
|
||||
|
||||
/// The `LastModified` header field.
|
||||
#[derive(Copy, PartialEq, Clone, Show)]
|
||||
#[derive(Copy, PartialEq, Clone, Debug)]
|
||||
pub struct LastModified(pub Tm);
|
||||
|
||||
deref!(LastModified => Tm);
|
||||
@@ -29,7 +29,7 @@ impl HeaderFormat for LastModified {
|
||||
0 => tm,
|
||||
_ => tm.to_utc(),
|
||||
};
|
||||
fmt::String::fmt(&tm.rfc822(), fmt)
|
||||
fmt::Display::fmt(&tm.rfc822(), fmt)
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -13,7 +13,7 @@ use header::parsing::from_one_raw_str;
|
||||
///
|
||||
/// Currently is just a String, but it should probably become a better type,
|
||||
/// like url::Url or something.
|
||||
#[derive(Clone, PartialEq, Show)]
|
||||
#[derive(Clone, PartialEq, Debug)]
|
||||
pub struct Location(pub String);
|
||||
|
||||
deref!(Location => String);
|
||||
|
||||
@@ -101,7 +101,7 @@ macro_rules! impl_list_header(
|
||||
}
|
||||
}
|
||||
|
||||
impl ::std::fmt::String for $from {
|
||||
impl ::std::fmt::Display for $from {
|
||||
fn fmt(&self, f: &mut ::std::fmt::Formatter) -> ::std::fmt::Result {
|
||||
use header::HeaderFormat;
|
||||
self.fmt_header(f)
|
||||
@@ -127,11 +127,11 @@ macro_rules! impl_header(
|
||||
|
||||
impl header::HeaderFormat for $from {
|
||||
fn fmt_header(&self, f: &mut ::std::fmt::Formatter) -> ::std::fmt::Result {
|
||||
::std::fmt::String::fmt(&**self, f)
|
||||
::std::fmt::Display::fmt(&**self, f)
|
||||
}
|
||||
}
|
||||
|
||||
impl ::std::fmt::String for $from {
|
||||
impl ::std::fmt::Display for $from {
|
||||
fn fmt(&self, f: &mut ::std::fmt::Formatter) -> ::std::fmt::Result {
|
||||
use header::HeaderFormat;
|
||||
self.fmt_header(f)
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
use header::{Header, HeaderFormat};
|
||||
use std::fmt::{self, Show};
|
||||
use std::fmt;
|
||||
use header::parsing::from_one_raw_str;
|
||||
|
||||
/// The `Referer` header.
|
||||
@@ -10,7 +10,7 @@ use header::parsing::from_one_raw_str;
|
||||
/// See alse [RFC 1945, section 10.13](http://tools.ietf.org/html/rfc1945#section-10.13).
|
||||
///
|
||||
/// Currently just a string, but maybe better replace it with url::Url or something like it.
|
||||
#[derive(Clone, PartialEq, Show)]
|
||||
#[derive(Clone, PartialEq, Debug)]
|
||||
pub struct Referer(pub String);
|
||||
|
||||
deref!(Referer => String);
|
||||
@@ -27,8 +27,7 @@ impl Header for Referer {
|
||||
|
||||
impl HeaderFormat for Referer {
|
||||
fn fmt_header(&self, fmt: &mut fmt::Formatter) -> fmt::Result {
|
||||
let Referer(ref value) = *self;
|
||||
value.fmt(fmt)
|
||||
fmt::Display::fmt(&self.0, fmt)
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -3,7 +3,7 @@ use header;
|
||||
/// The `Server` header field.
|
||||
///
|
||||
/// They can contain any value, so it just wraps a `String`.
|
||||
#[derive(Clone, PartialEq, Show)]
|
||||
#[derive(Clone, PartialEq, Debug)]
|
||||
pub struct Server(pub String);
|
||||
|
||||
impl_header!(Server,
|
||||
|
||||
@@ -10,7 +10,7 @@ use cookie::CookieJar;
|
||||
/// Informally, the Set-Cookie response header contains the header name
|
||||
/// "Set-Cookie" followed by a ":" and a cookie. Each cookie begins with
|
||||
/// a name-value-pair, followed by zero or more attribute-value pairs.
|
||||
#[derive(Clone, PartialEq, Show)]
|
||||
#[derive(Clone, PartialEq, Debug)]
|
||||
pub struct SetCookie(pub Vec<Cookie>);
|
||||
|
||||
deref!(SetCookie => Vec<Cookie>);
|
||||
|
||||
@@ -16,7 +16,7 @@ use header::parsing::{from_comma_delimited, fmt_comma_delimited};
|
||||
/// this header should include `chunked` as the last encoding.
|
||||
///
|
||||
/// The implementation uses a vector of `Encoding` values.
|
||||
#[derive(Clone, PartialEq, Show)]
|
||||
#[derive(Clone, PartialEq, Debug)]
|
||||
pub struct TransferEncoding(pub Vec<Encoding>);
|
||||
|
||||
deref!(TransferEncoding => Vec<Encoding>);
|
||||
|
||||
@@ -6,13 +6,13 @@ use header::parsing::{from_comma_delimited, fmt_comma_delimited};
|
||||
use self::Protocol::{WebSocket, ProtocolExt};
|
||||
|
||||
/// The `Upgrade` header.
|
||||
#[derive(Clone, PartialEq, Show)]
|
||||
#[derive(Clone, PartialEq, Debug)]
|
||||
pub struct Upgrade(pub Vec<Protocol>);
|
||||
|
||||
deref!(Upgrade => Vec<Protocol>);
|
||||
|
||||
/// Protocol values that can appear in the Upgrade header.
|
||||
#[derive(Clone, PartialEq, Show)]
|
||||
#[derive(Clone, PartialEq, Debug)]
|
||||
pub enum Protocol {
|
||||
/// The websocket protocol.
|
||||
WebSocket,
|
||||
@@ -29,7 +29,7 @@ impl FromStr for Protocol {
|
||||
}
|
||||
}
|
||||
|
||||
impl fmt::String for Protocol {
|
||||
impl fmt::Display for Protocol {
|
||||
fn fmt(&self, fmt: &mut fmt::Formatter) -> fmt::Result {
|
||||
write!(fmt, "{}", match *self {
|
||||
WebSocket => "websocket",
|
||||
|
||||
@@ -5,7 +5,7 @@ use header::parsing::from_one_raw_str;
|
||||
/// The `User-Agent` header field.
|
||||
///
|
||||
/// They can contain any value, so it just wraps a `String`.
|
||||
#[derive(Clone, PartialEq, Show)]
|
||||
#[derive(Clone, PartialEq, Debug)]
|
||||
pub struct UserAgent(pub String);
|
||||
|
||||
deref!(UserAgent => String);
|
||||
|
||||
@@ -6,7 +6,7 @@ use unicase::UniCase;
|
||||
/// The `Allow` header.
|
||||
/// See also https://tools.ietf.org/html/rfc7231#section-7.1.4
|
||||
|
||||
#[derive(Clone, PartialEq, Show)]
|
||||
#[derive(Clone, PartialEq, Debug)]
|
||||
pub enum Vary {
|
||||
/// This corresponds to '*'.
|
||||
Any,
|
||||
|
||||
@@ -267,7 +267,7 @@ impl Headers {
|
||||
}
|
||||
}
|
||||
|
||||
impl fmt::String for Headers {
|
||||
impl fmt::Display for Headers {
|
||||
fn fmt(&self, fmt: &mut fmt::Formatter) -> fmt::Result {
|
||||
for header in self.iter() {
|
||||
try!(write!(fmt, "{}\r\n", header));
|
||||
@@ -276,7 +276,7 @@ impl fmt::String for Headers {
|
||||
}
|
||||
}
|
||||
|
||||
impl fmt::Show for Headers {
|
||||
impl fmt::Debug for Headers {
|
||||
fn fmt(&self, fmt: &mut fmt::Formatter) -> fmt::Result {
|
||||
try!(fmt.write_str("Headers {{ "));
|
||||
for header in self.iter() {
|
||||
@@ -336,15 +336,15 @@ impl<'a> HeaderView<'a> {
|
||||
}
|
||||
}
|
||||
|
||||
impl<'a> fmt::String for HeaderView<'a> {
|
||||
impl<'a> fmt::Display for HeaderView<'a> {
|
||||
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
|
||||
write!(f, "{}: {}", self.0, *self.1.borrow())
|
||||
}
|
||||
}
|
||||
|
||||
impl<'a> fmt::Show for HeaderView<'a> {
|
||||
impl<'a> fmt::Debug for HeaderView<'a> {
|
||||
fn fmt(&self, fmt: &mut fmt::Formatter) -> fmt::Result {
|
||||
self.to_string().fmt(fmt)
|
||||
fmt::Display::fmt(self, fmt)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -448,7 +448,7 @@ unsafe fn downcast_mut<H: Header + HeaderFormat>(item: &mut Item) -> &mut H {
|
||||
item.typed.as_mut().expect("item.typed must be set").downcast_mut_unchecked()
|
||||
}
|
||||
|
||||
impl fmt::String for Item {
|
||||
impl fmt::Display for Item {
|
||||
fn fmt(&self, fmt: &mut fmt::Formatter) -> fmt::Result {
|
||||
match self.typed {
|
||||
Some(ref h) => h.fmt_header(fmt),
|
||||
@@ -472,13 +472,13 @@ impl fmt::String for Item {
|
||||
}
|
||||
|
||||
|
||||
impl fmt::Show for Box<HeaderFormat + Send + Sync> {
|
||||
impl fmt::Debug for Box<HeaderFormat + Send + Sync> {
|
||||
fn fmt(&self, fmt: &mut fmt::Formatter) -> fmt::Result {
|
||||
(**self).fmt_header(fmt)
|
||||
}
|
||||
}
|
||||
|
||||
impl fmt::String for Box<HeaderFormat + Send + Sync> {
|
||||
impl fmt::Display for Box<HeaderFormat + Send + Sync> {
|
||||
fn fmt(&self, fmt: &mut fmt::Formatter) -> fmt::Result {
|
||||
(**self).fmt_header(fmt)
|
||||
}
|
||||
@@ -491,13 +491,13 @@ impl fmt::String for Box<HeaderFormat + Send + Sync> {
|
||||
/// outgoing TcpStream.
|
||||
pub struct HeaderFormatter<'a, H: HeaderFormat>(pub &'a H);
|
||||
|
||||
impl<'a, H: HeaderFormat> fmt::String for HeaderFormatter<'a, H> {
|
||||
impl<'a, H: HeaderFormat> fmt::Display for HeaderFormatter<'a, H> {
|
||||
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
|
||||
self.0.fmt_header(f)
|
||||
}
|
||||
}
|
||||
|
||||
impl<'a, H: HeaderFormat> fmt::Show for HeaderFormatter<'a, H> {
|
||||
impl<'a, H: HeaderFormat> fmt::Debug for HeaderFormatter<'a, H> {
|
||||
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
|
||||
self.0.fmt_header(f)
|
||||
}
|
||||
|
||||
@@ -42,7 +42,7 @@ pub fn from_one_comma_delimited<T: str::FromStr>(raw: &[u8]) -> Option<Vec<T>> {
|
||||
}
|
||||
|
||||
/// Format an array into a comma-delimited string.
|
||||
pub fn fmt_comma_delimited<T: fmt::String>(fmt: &mut fmt::Formatter, parts: &[T]) -> fmt::Result {
|
||||
pub fn fmt_comma_delimited<T: fmt::Display>(fmt: &mut fmt::Formatter, parts: &[T]) -> fmt::Result {
|
||||
let last = parts.len() - 1;
|
||||
for (i, part) in parts.iter().enumerate() {
|
||||
try!(write!(fmt, "{}", part));
|
||||
|
||||
@@ -7,7 +7,7 @@ pub use self::Encoding::{Chunked, Gzip, Deflate, Compress, Identity, EncodingExt
|
||||
|
||||
/// A value to represent an encoding used in `Transfer-Encoding`
|
||||
/// or `Accept-Encoding` header.
|
||||
#[derive(Clone, PartialEq)]
|
||||
#[derive(Clone, PartialEq, Debug)]
|
||||
pub enum Encoding {
|
||||
/// The `chunked` encoding.
|
||||
Chunked,
|
||||
@@ -23,9 +23,9 @@ pub enum Encoding {
|
||||
EncodingExt(String)
|
||||
}
|
||||
|
||||
impl fmt::String for Encoding {
|
||||
impl fmt::Display for Encoding {
|
||||
fn fmt(&self, fmt: &mut fmt::Formatter) -> fmt::Result {
|
||||
write!(fmt, "{}", match *self {
|
||||
fmt.write_str(match *self {
|
||||
Chunked => "chunked",
|
||||
Gzip => "gzip",
|
||||
Deflate => "deflate",
|
||||
@@ -33,13 +33,7 @@ impl fmt::String for Encoding {
|
||||
Identity => "identity",
|
||||
EncodingExt(ref s) => s.as_slice()
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
impl fmt::Show for Encoding {
|
||||
fn fmt(&self, fmt: &mut fmt::Formatter) -> fmt::Result {
|
||||
self.to_string().fmt(fmt)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
impl str::FromStr for Encoding {
|
||||
|
||||
@@ -9,7 +9,7 @@ use std::str;
|
||||
|
||||
/// Represents an item with a quality value as defined in
|
||||
/// [RFC7231](https://tools.ietf.org/html/rfc7231#section-5.3.1).
|
||||
#[derive(Clone, PartialEq)]
|
||||
#[derive(Clone, PartialEq, Debug)]
|
||||
pub struct QualityItem<T> {
|
||||
/// The actual contents of the field.
|
||||
pub item: T,
|
||||
@@ -26,13 +26,7 @@ impl<T> QualityItem<T> {
|
||||
}
|
||||
}
|
||||
|
||||
impl<T: fmt::String> fmt::String for QualityItem<T> {
|
||||
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
|
||||
write!(f, "{}; q={}", self.item, format!("{:.3}", self.quality).trim_right_matches(['0', '.'].as_slice()))
|
||||
}
|
||||
}
|
||||
|
||||
impl<T: fmt::String> fmt::Show for QualityItem<T> {
|
||||
impl<T: fmt::Display> fmt::Display for QualityItem<T> {
|
||||
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
|
||||
write!(f, "{}; q={}", self.item, format!("{:.3}", self.quality).trim_right_matches(['0', '.'].as_slice()))
|
||||
}
|
||||
@@ -46,9 +40,9 @@ impl<T: str::FromStr> str::FromStr for QualityItem<T> {
|
||||
|
||||
let parts: Vec<&str> = s.rsplitn(1, ';').map(|x| x.trim()).collect();
|
||||
if parts.len() == 2 {
|
||||
let start = parts[0].slice(0, 2);
|
||||
let start = &parts[0][0..2];
|
||||
if start == "q=" || start == "Q=" {
|
||||
let q_part = parts[0].slice(2, parts[0].len());
|
||||
let q_part = &parts[0][2..parts[0].len()];
|
||||
if q_part.len() > 5 {
|
||||
return None;
|
||||
}
|
||||
|
||||
20
src/http.rs
20
src/http.rs
@@ -2,7 +2,6 @@
|
||||
use std::borrow::Cow::{Borrowed, Owned};
|
||||
use std::borrow::IntoCow;
|
||||
use std::cmp::min;
|
||||
use std::fmt;
|
||||
use std::io::{self, Reader, IoResult, BufWriter};
|
||||
use std::num::from_u16;
|
||||
use std::str::{self, FromStr};
|
||||
@@ -103,7 +102,7 @@ impl<R: Reader> Reader for HttpReader<R> {
|
||||
}
|
||||
|
||||
let to_read = min(rem as usize, buf.len());
|
||||
let count = try!(body.read(buf.slice_to_mut(to_read))) as u64;
|
||||
let count = try!(body.read(&mut buf[..to_read])) as u64;
|
||||
|
||||
rem -= count;
|
||||
*opt_remaining = if rem > 0 {
|
||||
@@ -306,23 +305,6 @@ pub const LF: u8 = b'\n';
|
||||
pub const STAR: u8 = b'*';
|
||||
pub const LINE_ENDING: &'static str = "\r\n";
|
||||
|
||||
/// A `Show`able struct to easily write line endings to a formatter.
|
||||
pub struct LineEnding;
|
||||
|
||||
impl Copy for LineEnding {}
|
||||
|
||||
impl fmt::String for LineEnding {
|
||||
fn fmt(&self, fmt: &mut fmt::Formatter) -> fmt::Result {
|
||||
fmt.write_str(LINE_ENDING)
|
||||
}
|
||||
}
|
||||
|
||||
impl fmt::Show for LineEnding {
|
||||
fn fmt(&self, fmt: &mut fmt::Formatter) -> fmt::Result {
|
||||
self.to_string().fmt(fmt)
|
||||
}
|
||||
}
|
||||
|
||||
/// Determines if byte is a token char.
|
||||
///
|
||||
/// > ```notrust
|
||||
|
||||
@@ -145,6 +145,7 @@ pub use status::StatusCode::{Ok, BadRequest, NotFound};
|
||||
pub use server::Server;
|
||||
|
||||
use std::error::{Error, FromError};
|
||||
use std::fmt;
|
||||
use std::io::IoError;
|
||||
|
||||
use self::HttpError::{HttpMethodError, HttpUriError, HttpVersionError,
|
||||
@@ -189,7 +190,7 @@ mod mimewrapper {
|
||||
pub type HttpResult<T> = Result<T, HttpError>;
|
||||
|
||||
/// A set of errors that can occur parsing HTTP streams.
|
||||
#[derive(Show, PartialEq, Clone)]
|
||||
#[derive(Debug, PartialEq, Clone)]
|
||||
pub enum HttpError {
|
||||
/// An invalid `Method`, such as `GE,T`.
|
||||
HttpMethodError,
|
||||
@@ -205,6 +206,12 @@ pub enum HttpError {
|
||||
HttpIoError(IoError),
|
||||
}
|
||||
|
||||
impl fmt::Display for HttpError {
|
||||
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
|
||||
f.write_str(self.description())
|
||||
}
|
||||
}
|
||||
|
||||
impl Error for HttpError {
|
||||
fn description(&self) -> &str {
|
||||
match *self {
|
||||
|
||||
@@ -13,7 +13,7 @@ use self::Method::{Options, Get, Post, Put, Delete, Head, Trace, Connect, Patch,
|
||||
///
|
||||
/// It may make sense to grow this to include all variants currently
|
||||
/// registered with IANA, if they are at all common to use.
|
||||
#[derive(Clone, PartialEq, Eq, Hash, Show)]
|
||||
#[derive(Clone, PartialEq, Eq, Hash, Debug)]
|
||||
pub enum Method {
|
||||
/// OPTIONS
|
||||
Options,
|
||||
@@ -88,9 +88,9 @@ impl FromStr for Method {
|
||||
}
|
||||
}
|
||||
|
||||
impl fmt::String for Method {
|
||||
impl fmt::Display for Method {
|
||||
fn fmt(&self, fmt: &mut fmt::Formatter) -> fmt::Result {
|
||||
match *self {
|
||||
fmt.write_str(match *self {
|
||||
Options => "OPTIONS",
|
||||
Get => "GET",
|
||||
Post => "POST",
|
||||
@@ -101,7 +101,7 @@ impl fmt::String for Method {
|
||||
Connect => "CONNECT",
|
||||
Patch => "PATCH",
|
||||
Extension(ref s) => s.as_slice()
|
||||
}.fmt(fmt)
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -25,7 +25,7 @@ impl PartialEq for MockStream {
|
||||
}
|
||||
}
|
||||
|
||||
impl fmt::Show for MockStream {
|
||||
impl fmt::Debug for MockStream {
|
||||
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
|
||||
write!(f, "MockStream {{ read: {:?}, write: {:?} }}",
|
||||
self.read.get_ref(), self.write.get_ref())
|
||||
|
||||
@@ -94,7 +94,7 @@ pub trait NetworkConnector {
|
||||
fn connect(&mut self, host: &str, port: Port, scheme: &str) -> IoResult<Self::Stream>;
|
||||
}
|
||||
|
||||
impl fmt::Show for Box<NetworkStream + Send> {
|
||||
impl fmt::Debug for Box<NetworkStream + Send> {
|
||||
fn fmt(&self, fmt: &mut fmt::Formatter) -> fmt::Result {
|
||||
fmt.pad("Box<NetworkStream>")
|
||||
}
|
||||
|
||||
@@ -26,7 +26,7 @@ use std::cmp::Ordering::{self, Less, Equal, Greater};
|
||||
/// # use hyper::status::StatusCode::{Code123, Continue};
|
||||
/// assert_eq!(Code123.class().default_code(), Continue);
|
||||
/// ```
|
||||
#[derive(Show)]
|
||||
#[derive(Debug)]
|
||||
pub enum StatusCode {
|
||||
/// 100 Continue
|
||||
Continue = 100,
|
||||
@@ -1589,7 +1589,7 @@ impl Copy for StatusCode {}
|
||||
/// ```
|
||||
///
|
||||
/// If you wish to just include the number, cast to a u16 instead.
|
||||
impl fmt::String for StatusCode {
|
||||
impl fmt::Display for StatusCode {
|
||||
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
|
||||
write!(f, "{} {}", *self as u16,
|
||||
self.canonical_reason().unwrap_or("<unknown status code>"))
|
||||
|
||||
@@ -16,7 +16,7 @@ use url::Url;
|
||||
/// > / authority-form
|
||||
/// > / asterisk-form
|
||||
/// > ```
|
||||
#[derive(Show, PartialEq, Clone)]
|
||||
#[derive(Debug, PartialEq, Clone)]
|
||||
pub enum RequestUri {
|
||||
/// The most common request target, an absolute path and optional query.
|
||||
///
|
||||
|
||||
@@ -7,7 +7,7 @@ use std::fmt;
|
||||
use self::HttpVersion::{Http09, Http10, Http11, Http20};
|
||||
|
||||
/// Represents a version of the HTTP spec.
|
||||
#[derive(PartialEq, PartialOrd, Copy, Show)]
|
||||
#[derive(PartialEq, PartialOrd, Copy, Debug)]
|
||||
pub enum HttpVersion {
|
||||
/// `HTTP/0.9`
|
||||
Http09,
|
||||
@@ -19,14 +19,14 @@ pub enum HttpVersion {
|
||||
Http20
|
||||
}
|
||||
|
||||
impl fmt::String for HttpVersion {
|
||||
impl fmt::Display for HttpVersion {
|
||||
fn fmt(&self, fmt: &mut fmt::Formatter) -> fmt::Result {
|
||||
match *self {
|
||||
fmt.write_str(match *self {
|
||||
Http09 => "HTTP/0.9",
|
||||
Http10 => "HTTP/1.0",
|
||||
Http11 => "HTTP/1.1",
|
||||
Http20 => "HTTP/2.0",
|
||||
}.fmt(fmt)
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user