///|
/// Why a connection ended.
#derive(Eq, Debug)
pub(all) enum DisconnectCause {
  /// The client sent a Close message, with its error text when it has one.
  ClientClosed(String?)
  /// The client sent nothing for the client timeout.
  TimedOut
  /// The client sent no complete handshake in the handshake timeout.
  HandshakeTimedOut
  /// The transport failed or the client ended it.
  TransportError(String)
  /// The client broke the protocol; the text names the fault.
  ProtocolViolation(String)
  /// The program closed the connection.
  ClosedByServer
  /// The client did not read its messages, and the queue of outgoing messages
  /// was full.
  SlowClient
  /// The server stopped with a drain.
  ServerStopped
}

///|
pub extend DisconnectCause with Eq::{equal, not_equal}

///|
pub extend DisconnectCause with @debug.Debug::{to_repr}