Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

refactor(lib): use non_exhaustive attribute #3420

Merged
merged 1 commit into from
Mar 28, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading