Error

Enum Error 

Source
pub enum Error {
Show 19 variants Io(Error), InvalidFrame(&'static str), InvalidUtf8, Protocol(&'static str), ConnectionClosed, MessageTooLarge, FrameTooLarge, InvalidHttp(&'static str), HandshakeFailed(&'static str), BufferFull, WouldBlock, ConnectionReset, InvalidState(&'static str), Closed(Option<CloseReason>), InvalidCloseCode(u16), Capacity(&'static str), Compression(String), ExtendedConnectNotSupported, StreamReset,
}
Expand description

WebSocket error types

Variants§

§

Io(Error)

I/O error from the underlying socket

§

InvalidFrame(&'static str)

Invalid WebSocket frame

§

InvalidUtf8

Invalid UTF-8 in text message

§

Protocol(&'static str)

Protocol violation

§

ConnectionClosed

Connection closed normally

§

MessageTooLarge

Message too large

§

FrameTooLarge

Frame too large

§

InvalidHttp(&'static str)

Invalid HTTP request

§

HandshakeFailed(&'static str)

Handshake failed

§

BufferFull

Buffer full (backpressure)

§

WouldBlock

Would block (non-blocking I/O)

§

ConnectionReset

Connection reset by peer

§

InvalidState(&'static str)

Invalid state

§

Closed(Option<CloseReason>)

Close frame received

§

InvalidCloseCode(u16)

Invalid close code

§

Capacity(&'static str)

Capacity exceeded

§

Compression(String)

Compression/decompression error

§

ExtendedConnectNotSupported

Extended CONNECT protocol not supported by server

§

StreamReset

Stream was reset by peer

Implementations§

Source§

impl Error

Source

pub fn kind(&self) -> ErrorKind

Get the error category/kind

Useful for metrics, logging, and error handling decisions.

Source

pub fn is_fatal(&self) -> bool

Check if this error is fatal (connection cannot continue)

Fatal errors indicate the connection is broken and cannot be recovered. Non-fatal errors may allow the connection to continue after handling.

Source

pub fn is_recoverable(&self) -> bool

Check if this error is recoverable

Recoverable errors are transient and the operation may succeed if retried.

Source

pub fn is_timeout(&self) -> bool

Check if this error is a timeout

Note: Timeout errors are typically wrapped by the caller using tokio::time::timeout, but some transport errors may indicate timeouts.

Source

pub fn is_connection_error(&self) -> bool

Check if this error is a connection error

Source

pub fn is_protocol_error(&self) -> bool

Check if this error is a protocol error

Source

pub fn metric_name(&self) -> &'static str

Get a metric-friendly name for this error

Returns a short, lowercase, underscore-separated string suitable for use in metrics labels.

Source

pub fn suggested_http_status(&self) -> u16

Get a suggested HTTP status code for this error

Useful when converting WebSocket errors to HTTP responses during handshake or in HTTP/2/HTTP/3 contexts.

Trait Implementations§

Source§

impl Debug for Error

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl Display for Error

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl Error for Error

Source§

fn source(&self) -> Option<&(dyn Error + 'static)>

Returns the lower-level source of this error, if any. Read more
1.0.0 · Source§

fn description(&self) -> &str

👎Deprecated since 1.42.0: use the Display impl or to_string()
1.0.0 · Source§

fn cause(&self) -> Option<&dyn Error>

👎Deprecated since 1.33.0: replaced by Error::source, which can support downcasting
Source§

fn provide<'a>(&'a self, request: &mut Request<'a>)

🔬This is a nightly-only experimental API. (error_generic_member_access)
Provides type-based access to context intended for error reports. Read more
Source§

impl From<Error> for Error

Source§

fn from(e: Error) -> Self

Converts to this type from the input type.
Source§

impl From<Error> for Error

Source§

fn from(e: Error) -> Self

Converts to this type from the input type.

Auto Trait Implementations§

§

impl Freeze for Error

§

impl !RefUnwindSafe for Error

§

impl Send for Error

§

impl Sync for Error

§

impl Unpin for Error

§

impl !UnwindSafe for Error

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
Source§

impl<T> ToString for T
where T: Display + ?Sized,

Source§

fn to_string(&self) -> String

Converts the given value to a String. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.