pub enum DisconnectOrigin {
OnConnectAbort,
Reading,
Shutdown,
User,
Writing,
}Expand description
Describes what triggered a disconnect, as delivered to Disconnect::handle_disconnect.
note: Handshake failures do not appear here. A failed handshake prevents the connection from ever being registered, so there is no connection to disconnect.
note: When several events would race to trigger a disconnect on the same connection,
only the first to claim it is delivered to Disconnect::handle_disconnect; subsequent
claims are silently dropped.
Variants§
OnConnectAbort
The OnConnect task terminated abnormally before defusing its connection cleanup.
In practice this almost always means the user’s OnConnect::on_connect implementation
panicked, and the disconnect is a side effect of that panic unwinding past the cleanup
guard.
Reading
The reader task for this connection terminated. Typical causes are the peer closing
its end of the socket, a decode error from the user-supplied Reading::Codec, or
no message arriving within [Reading::IDLE_TIMEOUT_MS]. Often (but not always)
indicates a peer-side issue.
Shutdown
The disconnect was initiated by Tcp::shut_down, which tears down every active
connection as part of stopping the node. Unlike DisconnectOrigin::User, this
signals that the entire node is going away - reconnection is not meaningful.
User
The disconnect was explicitly requested via Tcp::disconnect. This is the only
origin produced directly by user code; the others all reflect events the library
detected internally.
Writing
The writer task for this connection terminated. Typical causes are a [Writing::TIMEOUT_MS]
timeout while flushing, an underlying socket write error, or the message channel being
closed. Often correlates with the peer disappearing, but can also reflect local-side
pipeline problems (slow consumer, broken pipe).
Trait Implementations§
Source§impl Clone for DisconnectOrigin
impl Clone for DisconnectOrigin
Source§fn clone(&self) -> DisconnectOrigin
fn clone(&self) -> DisconnectOrigin
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read more