Skip to content

Commit

Permalink
refactor(lib): use non_exhaustive attribute (#3420)
Browse files Browse the repository at this point in the history
  • Loading branch information
tottoto authored Mar 28, 2024
1 parent 12ab310 commit bc9a86f
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 15 deletions.
14 changes: 3 additions & 11 deletions src/client/conn/http1.rs
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ pub struct SendRequest<B> {
/// This allows taking apart a `Connection` at a later time, in order to
/// reclaim the IO object, and additional related pieces.
#[derive(Debug)]
#[non_exhaustive]
pub struct Parts<T> {
/// The original IO object used in the handshake.
pub io: T,
Expand All @@ -41,7 +42,6 @@ pub struct Parts<T> {
/// You will want to check for any existing bytes if you plan to continue
/// communicating on the IO object.
pub read_buf: Bytes,
_inner: (),
}

/// A future that processes all HTTP state for the IO object.
Expand All @@ -68,11 +68,7 @@ where
/// Only works for HTTP/1 connections. HTTP/2 connections will panic.
pub fn into_parts(self) -> Parts<T> {
let (io, read_buf, _) = self.inner.into_inner();
Parts {
io,
read_buf,
_inner: (),
}
Parts { io, read_buf }
}

/// Poll the connection for completion, but without calling `shutdown`
Expand Down Expand Up @@ -589,11 +585,7 @@ mod upgrades {
match ready!(Pin::new(&mut self.inner.as_mut().unwrap().inner).poll(cx)) {
Ok(proto::Dispatched::Shutdown) => Poll::Ready(Ok(())),
Ok(proto::Dispatched::Upgrade(pending)) => {
let Parts {
io,
read_buf,
_inner,
} = self.inner.take().unwrap().into_parts();
let Parts { io, read_buf } = self.inner.take().unwrap().into_parts();
pending.fulfill(Upgraded::new(io, read_buf));
Poll::Ready(Ok(()))
}
Expand Down
3 changes: 1 addition & 2 deletions src/server/conn/http1.rs
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,7 @@ pub struct Builder {
/// This allows taking apart a `Connection` at a later time, in order to
/// reclaim the IO object, and additional related pieces.
#[derive(Debug)]
#[non_exhaustive]
pub struct Parts<T, S> {
/// The original IO object used in the handshake.
pub io: T,
Expand All @@ -100,7 +101,6 @@ pub struct Parts<T, S> {
pub read_buf: Bytes,
/// The `Service` used to serve this connection.
pub service: S,
_inner: (),
}

// ===== impl Connection =====
Expand Down Expand Up @@ -151,7 +151,6 @@ where
io,
read_buf,
service: dispatch.into_service(),
_inner: (),
}
}

Expand Down
3 changes: 1 addition & 2 deletions src/upgrade.rs
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,7 @@ pub struct OnUpgrade {
/// Includes the original IO type, and a read buffer of bytes that the
/// HTTP state machine may have already read before completing an upgrade.
#[derive(Debug)]
#[non_exhaustive]
pub struct Parts<T> {
/// The original IO object used before the upgrade.
pub io: T,
Expand All @@ -91,7 +92,6 @@ pub struct Parts<T> {
/// You will want to check for any existing bytes if you plan to continue
/// communicating on the IO object.
pub read_buf: Bytes,
_inner: (),
}

/// Gets a pending HTTP upgrade from this message.
Expand Down Expand Up @@ -154,7 +154,6 @@ impl Upgraded {
Ok(t) => Ok(Parts {
io: *t,
read_buf: buf,
_inner: (),
}),
Err(io) => Err(Upgraded {
io: Rewind::new_buffered(io, buf),
Expand Down

1 comment on commit bc9a86f

@github-actions
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Performance Alert ⚠️

Possible performance regression was detected for benchmark 'end_to_end'.
Benchmark result of this commit is worse than the previous benchmark result exceeding threshold 2.

Benchmark suite Current: bc9a86f Previous: 12ab310 Ratio
http2_parallel_x10_req_10kb_100_chunks_adaptive_window 32818348 ns/iter (± 18358133) 7931537 ns/iter (± 380493) 4.14

This comment was automatically generated by workflow using github-action-benchmark.

Please sign in to comment.