feat(debug): add Debug impls for StatusClass, Server, and Listening
This commit is contained in:
		| @@ -1,4 +1,5 @@ | |||||||
| //! HTTP Server | //! HTTP Server | ||||||
|  | use std::fmt; | ||||||
| use std::io::{ErrorKind, BufWriter, Write}; | use std::io::{ErrorKind, BufWriter, Write}; | ||||||
| use std::marker::PhantomData; | use std::marker::PhantomData; | ||||||
| use std::net::{SocketAddr, ToSocketAddrs}; | use std::net::{SocketAddr, ToSocketAddrs}; | ||||||
| @@ -34,6 +35,7 @@ mod listener; | |||||||
| /// | /// | ||||||
| /// Once listening, it will create a `Request`/`Response` pair for each | /// Once listening, it will create a `Request`/`Response` pair for each | ||||||
| /// incoming connection, and hand them to the provided handler. | /// incoming connection, and hand them to the provided handler. | ||||||
|  | #[derive(Debug)] | ||||||
| pub struct Server<'a, H: Handler, L = HttpListener> { | pub struct Server<'a, H: Handler, L = HttpListener> { | ||||||
|     handler: H, |     handler: H, | ||||||
|     ssl: Option<(&'a Path, &'a Path)>, |     ssl: Option<(&'a Path, &'a Path)>, | ||||||
| @@ -187,6 +189,12 @@ pub struct Listening { | |||||||
|     pub socket: SocketAddr, |     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 { | impl Drop for Listening { | ||||||
|     fn drop(&mut self) { |     fn drop(&mut self) { | ||||||
|         let _ = self._guard.take().map(|g| g.join()); |         let _ = self._guard.take().map(|g| g.join()); | ||||||
|   | |||||||
| @@ -558,7 +558,7 @@ impl Ord for StatusCode { | |||||||
| /// | /// | ||||||
| /// This can be used in cases where a status code’s meaning is unknown, also, | /// This can be used in cases where a status code’s meaning is unknown, also, | ||||||
| /// to get the appropriate *category* of status. | /// 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 { | pub enum StatusClass { | ||||||
|     /// 1xx (Informational): The request was received, continuing process |     /// 1xx (Informational): The request was received, continuing process | ||||||
|     Informational, |     Informational, | ||||||
|   | |||||||
		Reference in New Issue
	
	Block a user