#[repr(u16)]pub enum CloseCode {
Show 16 variants
NormalClosure = 1_000,
GoingAway = 1_001,
ProtocolError = 1_002,
UnsupportedData = 1_003,
NoStatusRcvd = 1_005,
AbnormalClosure = 1_006,
InvalidFramePayloadData = 1_007,
PolicyViolation = 1_008,
MessageTooBig = 1_009,
MandatoryExt = 1_010,
InternalError = 1_011,
ServiceRestart = 1_012,
TryAgainLater = 1_013,
BadGateway = 1_014,
TlsHandshake = 1_015,
Other(u16),
}
Expand description
A close code indicating why a WebSocket connection was closed.
Variantsยง
NormalClosure = 1_000
The connection successfully completed the purpose for which it was created.
GoingAway = 1_001
The endpoint is going away, either because of a server failure or a navigation away.
ProtocolError = 1_002
The endpoint is terminating the connection due to a protocol error.
UnsupportedData = 1_003
The connection is being terminated because the endpoint received data of a type it cannot accept.
NoStatusRcvd = 1_005
Reserved: Indicates that no status code was provided although one was expected.
AbnormalClosure = 1_006
Reserved: Indicates that a connection was closed abnormally when a status code was expected.
InvalidFramePayloadData = 1_007
The endpoint is terminating the connection because a message has inconsistent data.
PolicyViolation = 1_008
The endpoint is terminating the connection because it received a message that violates its policy.
MessageTooBig = 1_009
The endpoint is terminating the connection because a data frame was received that is too large.
MandatoryExt = 1_010
The client is terminating the connection because it expected a server extension negotiation.
InternalError = 1_011
The server is terminating the connection because it encountered an unexpected condition.
ServiceRestart = 1_012
The server is terminating the connection because it is restarting.
TryAgainLater = 1_013
The server is terminating the connection due to a temporary condition (e.g., overloaded).
BadGateway = 1_014
The server was acting as a gateway or proxy and received an invalid response from upstream.
TlsHandshake = 1_015
Reserved: The connection was closed due to a failure in the TLS handshake.
Other(u16)
Other close code.
Implementationsยง
Sourceยงimpl CloseCode
impl CloseCode
Sourcepub fn is_valid(&self) -> bool
pub fn is_valid(&self) -> bool
Whether the close code can be specified when closing a WebSocket using WebSocket::close_with_reason.
The close code is valid if it is either CloseCode::NormalClosure or CloseCode::Other with a value between 3000 and 4999.