Skip to content

Commit c0c2bf8

Browse files
committed
feat(error): using Infallible instead of NoError
Signed-off-by: Jad K. Haddad <jadkhaddad@gmail.com>
1 parent 1494797 commit c0c2bf8

1 file changed

Lines changed: 6 additions & 8 deletions

File tree

src/error.rs

Lines changed: 6 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
use core::convert::Infallible;
2+
13
#[derive(Debug, thiserror::Error)]
24
pub enum FrameDecodeError {
35
#[error("Reserved bits must be zero")]
@@ -10,7 +12,7 @@ pub enum FrameDecodeError {
1012
MaskedFrameFromServer,
1113
#[error("Invalid opcode")]
1214
InvalidOpCode,
13-
// The payload length comes as an u64, converting it to usize might fail on 32-bit systems
15+
// The payload length comes as a u64, converting it to usize might fail on 32-bit systems
1416
#[error("Payload too large")]
1517
PayloadTooLarge,
1618
#[error("Control frame fragmented")]
@@ -103,12 +105,8 @@ pub enum WriteError<I> {
103105
}
104106

105107
#[derive(Debug, thiserror::Error)]
106-
#[error("NoError")]
107-
pub struct NoError {}
108-
109-
#[derive(Debug, thiserror::Error)]
110-
pub enum HandshakeError<E = NoError> {
111-
/// Use of the wrong HTTP method (the WebSocket protocol requires the GET method be used).
108+
pub enum HandshakeError<E = Infallible> {
109+
/// Use of the wrong HTTP method (the WebSocket protocol requires the GET method to be used).
112110
#[error("Unsupported HTTP method used - only GET is allowed")]
113111
WrongHttpMethod,
114112
/// Wrong HTTP version used (the WebSocket protocol requires version 1.1 or higher).
@@ -141,7 +139,7 @@ pub enum FragmentationError {
141139
}
142140

143141
#[derive(Debug, thiserror::Error)]
144-
pub enum Error<I, E = NoError> {
142+
pub enum Error<I, E = Infallible> {
145143
#[error("Read error: {0}")]
146144
Read(
147145
#[from]

0 commit comments

Comments
 (0)