#[non_exhaustive]pub enum WsErr {
Utf8(Utf8Error),
InvalidWsState {
supplied: u16,
},
ConnectionNotOpen,
InvalidUrl {
supplied: String,
},
InvalidCloseCode {
supplied: u16,
},
ReasonStringToLong,
ConnectionFailed {
event: CloseEvent,
},
InvalidEncoding,
CantDecodeBlob,
UnknownDataType,
Dom(u16),
Other(String),
}
Expand description
The error type for errors happening in ws_stream_wasm
.
Variants (Non-exhaustive)§
This enum is marked as non-exhaustive
Utf8(Utf8Error)
UTF-8 error
InvalidWsState
Invalid input to WsState::try_from( u16 ).
ConnectionNotOpen
When trying to send and WsState is anything but WsState::Open this error is returned.
InvalidUrl
An invalid URL was given to WsMeta::connect, please see: HTML Living Standard.
InvalidCloseCode
An invalid close code was given to a close method. For valid close codes, please see: MDN Documentation.
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
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
.