[][src]Enum ws_stream_wasm::WsErr

#[non_exhaustive]pub enum WsErr {
    InvalidWsState {
        supplied: u16,
    },
    ConnectionNotOpen,
    ForbiddenPort,
    InvalidUrl {
        supplied: String,
    },
    InvalidCloseCode {
        supplied: u16,
    },
    ReasonStringToLong,
    ConnectionFailed {
        event: CloseEvent,
    },
    InvalidEncoding,
    CantDecodeBlob,
    UnknownDataType,
}

The error type for errors happening in ws_stream_wasm.

Variants (Non-exhaustive)

Non-exhaustive enums could have additional variants added in future. Therefore, when matching against variants of non-exhaustive enums, an extra wildcard arm must be added to account for any future variants.
InvalidWsState

Invalid input to WsState::try_from( u16 ).

Fields of InvalidWsState

supplied: u16

The user supplied value that is invalid.

ConnectionNotOpen

When trying to send and WsState is anything but WsState::Open this error is returned.

ForbiddenPort

Browsers will forbid making websocket connections to certain ports. See this Stack Overflow question.

InvalidUrl

An invalid URL was given to WsMeta::connect, please see: HTML Living Standard.

Fields of InvalidUrl

supplied: String

The user supplied value that is invalid.

InvalidCloseCode

An invalid close code was given to a close method. For valid close codes, please see: MDN Documentation.

Fields of InvalidCloseCode

supplied: u16

The user supplied value that is invalid.

ReasonStringToLong

The reason string given to a close method is longer than 123 bytes, please see: MDN Documentation.

ConnectionFailed

Failed to connect to the server.

Fields of ConnectionFailed

event: CloseEvent

The close event that might hold extra code and reason information.

InvalidEncoding

When converting the JavaScript Message into a WsMessage, it's possible that a String message doesn't convert correctly as Js does not guarantee that strings are valid Unicode. Happens in impl TryFrom< MessageEvent > for WsMessage.

CantDecodeBlob

When converting the JavaScript Message into a WsMessage, it's not possible to convert Blob type messages, as Blob is a streaming type, that needs to be read asynchronously. If you are using the type without setting up the connection with [WsMeta::connect], you have to make sure to set the binary type of the connection to ArrayBuffer.

Happens in impl TryFrom< MessageEvent > for WsMessage.

UnknownDataType

When converting the JavaScript Message into a WsMessage, the data type was neither Arraybuffer, String nor Blob. This should never happen. If it does, please try to make a reproducible example and file an issue.

Happens in impl TryFrom< MessageEvent > for WsMessage.

Trait Implementations

impl Clone for WsErr[src]

impl Debug for WsErr[src]

impl Display for WsErr[src]

impl Eq for WsErr[src]

impl Error for WsErr[src]

impl PartialEq<WsErr> for WsErr[src]

impl StructuralEq for WsErr[src]

impl StructuralPartialEq for WsErr[src]

Auto Trait Implementations

impl RefUnwindSafe for WsErr

impl Send for WsErr

impl Sync for WsErr

impl Unpin for WsErr

impl UnwindSafe for WsErr

Blanket Implementations

impl<T> Any for T where
    T: 'static + ?Sized
[src]

impl<T> Borrow<T> for T where
    T: ?Sized
[src]

impl<T> BorrowMut<T> for T where
    T: ?Sized
[src]

impl<T> From<T> for T[src]

impl<T, U> Into<U> for T where
    U: From<T>, 
[src]

impl<T> ToOwned for T where
    T: Clone
[src]

type Owned = T

The resulting type after obtaining ownership.

impl<T> ToString for T where
    T: Display + ?Sized
[src]

impl<T, U> TryFrom<U> for T where
    U: Into<T>, 
[src]

type Error = Infallible

The type returned in the event of a conversion error.

impl<T, U> TryInto<U> for T where
    U: TryFrom<T>, 
[src]

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

The type returned in the event of a conversion error.