Skip to content

Commit

Permalink
fix: missing_debug_implementations
Browse files Browse the repository at this point in the history
Public types should have `std::fmt::Debug` implementations.

Signed-off-by: Jonathan Woollett-Light <jcawl@amazon.co.uk>
  • Loading branch information
Jonathan Woollett-Light committed Sep 21, 2023
1 parent a4d632f commit 2003663
Show file tree
Hide file tree
Showing 5 changed files with 20 additions and 3 deletions.
2 changes: 1 addition & 1 deletion coverage_config_x86_64.json
Original file line number Diff line number Diff line change
@@ -1 +1 @@
{"coverage_score": 87.9, "exclude_path": "", "crate_features": ""}
{"coverage_score": 85.9, "exclude_path": "", "crate_features": ""}
2 changes: 2 additions & 0 deletions src/connection.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand All @@ -27,6 +28,7 @@ enum ConnectionState {
}

/// A wrapper over a HTTP Connection.
#[derive(Debug)]
pub struct HttpConnection<T> {
/// A partial request that is still being received.
pending_request: Option<Request>,
Expand Down
2 changes: 1 addition & 1 deletion src/lib.rs
Original file line number Diff line number Diff line change
@@ -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.
//!
Expand Down
12 changes: 12 additions & 0 deletions src/router.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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};

Expand All @@ -24,6 +25,17 @@ pub struct HttpRoutes<T> {
routes: HashMap<String, Box<dyn EndpointHandler<T> + Sync + Send>>,
}

impl<T> fmt::Debug for HttpRoutes<T> {
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<T: Send> HttpRoutes<T> {
/// Create a http request router.
pub fn new(server_id: String, prefix: String) -> Self {
Expand Down
5 changes: 4 additions & 1 deletion src/server.rs
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,7 @@ impl ServerRequest {
}

/// Wrapper over `Response` which adds an identification token.
#[derive(Debug)]
pub struct ServerResponse {
/// Inner response.
response: Response,
Expand All @@ -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,
Expand All @@ -83,6 +84,7 @@ enum ClientConnectionState {

/// Wrapper over `HttpConnection` which keeps track of yielded
/// requests and absorbed responses.
#[derive(Debug)]
struct ClientConnection<T> {
/// The `HttpConnection` object which handles data exchange.
connection: HttpConnection<T>,
Expand Down Expand Up @@ -249,6 +251,7 @@ impl<T: Read + Write + ScmSocket> ClientConnection<T> {
/// break;
/// }
/// ```
#[derive(Debug)]
pub struct HttpServer {
/// Socket on which we listen for new connections.
socket: UnixListener,
Expand Down

0 comments on commit 2003663

Please sign in to comment.