Skip to main content

CloseReason

Enum CloseReason 

Source
#[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
Non-exhaustive enums could have additional variants added in future. Therefore, when matching against variants of non-exhaustive enums, an extra wildcard arm must be added to account for any future variants.
§

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.

Fields

§direction: Direction

In which direction.

§

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

Source

pub fn as_str(&self) -> &'static str

A stable snake_case name for logs.

assert_eq!(net_io::CloseReason::Idle.as_str(), "idle");
Source

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());

Trait Implementations§

Source§

impl Clone for CloseReason

Source§

fn clone(&self) -> Self

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Copy for CloseReason

Source§

impl Debug for CloseReason

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl Display for CloseReason

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl Eq for CloseReason

Source§

impl Hash for CloseReason

Source§

fn hash<__H: Hasher>(&self, state: &mut __H)

Feeds this value into the given Hasher. Read more
1.3.0 · Source§

fn hash_slice<H>(data: &[Self], state: &mut H)
where H: Hasher, Self: Sized,

Feeds a slice of this type into the given Hasher. Read more
Source§

impl PartialEq for CloseReason

Source§

fn eq(&self, other: &Self) -> bool

Equality operator ==. Read more
1.0.0 (const: unstable) · Source§

fn ne(&self, other: &Rhs) -> bool

Inequality operator !=. Read more
Source§

impl StructuralPartialEq for CloseReason

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T> ToString for T
where T: Display + ?Sized,

Source§

fn to_string(&self) -> String

Converts the given value to a String. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = !

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, !>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.