diff --git a/coverage_config_x86_64.json b/coverage_config_x86_64.json index f28298a..7668d20 100644 --- a/coverage_config_x86_64.json +++ b/coverage_config_x86_64.json @@ -1 +1 @@ -{"coverage_score": 87.9, "exclude_path": "", "crate_features": ""} +{"coverage_score": 85.9, "exclude_path": "", "crate_features": ""} diff --git a/src/connection.rs b/src/connection.rs index 3bd0d59..969e0f6 100644 --- a/src/connection.rs +++ b/src/connection.rs @@ -19,6 +19,7 @@ const BUFFER_SIZE: usize = 1024; const SCM_MAX_FD: usize = 253; /// Describes the state machine of an HTTP connection. +#[derive(Debug)] enum ConnectionState { WaitingForRequestLine, WaitingForHeaders, @@ -27,6 +28,7 @@ enum ConnectionState { } /// A wrapper over a HTTP Connection. +#[derive(Debug)] pub struct HttpConnection { /// A partial request that is still being received. pending_request: Option, diff --git a/src/lib.rs b/src/lib.rs index d16a3bb..df16b64 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -1,6 +1,6 @@ // Copyright 2018 Amazon.com, Inc. or its affiliates. All Rights Reserved. // SPDX-License-Identifier: Apache-2.0 -#![deny(missing_docs)] +#![deny(missing_docs, missing_debug_implementations)] //! Minimal implementation of the [HTTP/1.0](https://tools.ietf.org/html/rfc1945) //! and [HTTP/1.1](https://www.ietf.org/rfc/rfc2616.txt) protocols. //! diff --git a/src/router.rs b/src/router.rs index a2171c3..4676459 100644 --- a/src/router.rs +++ b/src/router.rs @@ -4,6 +4,7 @@ // SPDX-License-Identifier: Apache-2.0 use std::collections::hash_map::{Entry, HashMap}; +use std::fmt; use crate::{MediaType, Method, Request, Response, StatusCode, Version}; @@ -24,6 +25,17 @@ pub struct HttpRoutes { routes: HashMap + Sync + Send>>, } +impl fmt::Debug for HttpRoutes { + fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { + f.debug_struct("HttpRoutes") + .field("server_id", &self.server_id) + .field("prefix", &self.prefix) + .field("media_type", &self.media_type) + .field("routes", &"{ .. }") + .finish() + } +} + impl HttpRoutes { /// Create a http request router. pub fn new(server_id: String, prefix: String) -> Self { diff --git a/src/server.rs b/src/server.rs index 2eff27f..b77bc28 100644 --- a/src/server.rs +++ b/src/server.rs @@ -59,6 +59,7 @@ impl ServerRequest { } /// Wrapper over `Response` which adds an identification token. +#[derive(Debug)] pub struct ServerResponse { /// Inner response. response: Response, @@ -74,7 +75,7 @@ impl ServerResponse { /// Describes the state of the connection as far as data exchange /// on the stream is concerned. -#[derive(PartialOrd, PartialEq)] +#[derive(Debug, PartialOrd, PartialEq)] enum ClientConnectionState { AwaitingIncoming, AwaitingOutgoing, @@ -83,6 +84,7 @@ enum ClientConnectionState { /// Wrapper over `HttpConnection` which keeps track of yielded /// requests and absorbed responses. +#[derive(Debug)] struct ClientConnection { /// The `HttpConnection` object which handles data exchange. connection: HttpConnection, @@ -249,6 +251,7 @@ impl ClientConnection { /// break; /// } /// ``` +#[derive(Debug)] pub struct HttpServer { /// Socket on which we listen for new connections. socket: UnixListener,