Skip to content

Commit

Permalink
refactor(lib): use non_exhaustive attribute
Browse files Browse the repository at this point in the history
  • Loading branch information
tottoto committed Nov 16, 2023
1 parent b855475 commit 1521bdc
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 @@ -28,6 +28,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 @@ -40,7 +41,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 @@ -67,11 +67,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 @@ -562,11 +558,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 @@ -84,6 +84,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 @@ -98,7 +99,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 @@ -149,7 +149,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 @@ -80,6 +80,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 @@ -92,7 +93,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 @@ -155,7 +155,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

0 comments on commit 1521bdc

Please sign in to comment.