#[non_exhaustive]pub enum CloseReason {
Show 26 variants
PeerClosed,
PeerReset,
Idle,
HandshakeTimeout,
ReadTimeout,
WriteTimeout,
ExchangeDeadline,
ParkDeadline,
SlowPeer {
direction: Direction,
},
Refused(RefusalCause),
ProxyUntrusted,
ProxyMissing,
ProxyInvalid,
TlsFailed,
HelloRefused,
Killed(KillReason),
EgressDenied(u16),
Drained,
DrainDeadline,
Shed,
Shutdown,
SessionClosed,
SessionError,
SessionPanicked,
Limit(LimitKind),
Io(OsErrorClass),
}Expand description
Why a connection closed. Every connection ends with exactly one.
§Examples
use net_io::{CloseReason, Direction};
let reason = CloseReason::SlowPeer { direction: Direction::In };
assert_eq!(reason.as_str(), "slow_peer_in");
assert!(reason.is_abortive());
assert!(!CloseReason::PeerClosed.is_abortive());Variants (Non-exhaustive)§
This enum is marked as non-exhaustive
PeerClosed
The peer closed its side and the session closed.
PeerReset
The peer sent RST.
Idle
No exchange started within the idle timeout.
HandshakeTimeout
The PROXY header and TLS handshake did not finish within the handshake timeout.
ReadTimeout
No progress within the read timeout.
WriteTimeout
No progress within the write timeout.
ExchangeDeadline
The session’s deadline for the current exchange passed.
ParkDeadline
A parked connection was not woken in time.
SlowPeer
The minimum transfer rate was not met.
Refused(RefusalCause)
Refused at accept or by the session factory.
ProxyUntrusted
A PROXY-required listener got a connection from an untrusted peer.
ProxyMissing
A trusted peer sent no PROXY header.
ProxyInvalid
The PROXY header was malformed or too large.
TlsFailed
The TLS engine failed.
HelloRefused
The TLS engine’s hello hook refused the ClientHello.
Killed(KillReason)
A kill handle closed the connection.
EgressDenied(u16)
The gate denied a write.
Drained
The session finished after drain started.
DrainDeadline
The session had not finished when the drain deadline passed.
Shed
The control line shed this lane.
Shutdown
The control line said Stopping, or the server shut down.
SessionClosed
The session returned Step::Close.
SessionError
The session returned Step::Abort, or a handler returned an error.
SessionPanicked
The session panicked.
Limit(LimitKind)
A per-connection bound was hit.
Io(OsErrorClass)
The OS reported an error not covered above.
Implementations§
Source§impl CloseReason
impl CloseReason
Sourcepub fn as_str(&self) -> &'static str
pub fn as_str(&self) -> &'static str
A stable snake_case name for logs.
assert_eq!(net_io::CloseReason::Idle.as_str(), "idle");Sourcepub fn is_abortive(&self) -> bool
pub fn is_abortive(&self) -> bool
Whether the connection is closed with RST (true) or gracefully with FIN (false).
assert!(net_io::CloseReason::ReadTimeout.is_abortive());