feat(debug): add Debug impls for StatusClass, Server, and Listening

This commit is contained in:
Sean McArthur
2015-04-16 10:04:51 -07:00
parent 9a8ea4a267
commit 0fb92ee735
3 changed files with 10 additions and 2 deletions

View File

@@ -349,7 +349,7 @@ pub enum RedirectPolicy {
// This is a hack because of upstream typesystem issues.
impl Clone for RedirectPolicy {
fn clone(&self) -> RedirectPolicy {
*self
*self
}
}

View File

@@ -1,4 +1,5 @@
//! HTTP Server
use std::fmt;
use std::io::{ErrorKind, BufWriter, Write};
use std::marker::PhantomData;
use std::net::{SocketAddr, ToSocketAddrs};
@@ -34,6 +35,7 @@ mod listener;
///
/// Once listening, it will create a `Request`/`Response` pair for each
/// incoming connection, and hand them to the provided handler.
#[derive(Debug)]
pub struct Server<'a, H: Handler, L = HttpListener> {
handler: H,
ssl: Option<(&'a Path, &'a Path)>,
@@ -187,6 +189,12 @@ pub struct Listening {
pub socket: SocketAddr,
}
impl fmt::Debug for Listening {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
write!(f, "Listening {{ socket: {:?} }}", self.socket)
}
}
impl Drop for Listening {
fn drop(&mut self) {
let _ = self._guard.take().map(|g| g.join());

View File

@@ -558,7 +558,7 @@ impl Ord for StatusCode {
///
/// This can be used in cases where a status codes meaning is unknown, also,
/// to get the appropriate *category* of status.
#[derive(Clone, PartialEq, Eq, PartialOrd, Ord, Copy)]
#[derive(Debug, Clone, PartialEq, Eq, PartialOrd, Ord, Copy)]
pub enum StatusClass {
/// 1xx (Informational): The request was received, continuing process
Informational,