Struct LingeringClose
pub struct LingeringClose { /* private fields */ }net only.Expand description
Bounds of a lingering close: after shutting down its own side, a connection keeps reading and discarding what its peer still sends before it is closed.
Closing a socket that still has unread input sends a reset instead of a
clean close, and on Windows a reset makes the peer discard what it has
not read yet, such as the tail of a response that was just sent to it.
The same happens when the peer sends after the socket was closed.
Lingering keeps the socket open until the peer is done, as nginx does
with lingering_close.
A connection lingers until its peer ends the stream, nothing arrives for
idle_timeout, timeout passes
in total, or max_bytes (if set) were read and
discarded, whichever comes first. A peer that is still sending is waited
for, so the total timeout is what bounds a slow one. Used by
IoForwardService and rama’s HTTP/1
server, which say when a connection lingers.
The total of 30 seconds is nginx’s lingering_time. The idle timeout of
2 seconds is shorter than nginx’s lingering_timeout of 5, as the peer
only has to finish what it was already sending.
Implementations§
§impl LingeringClose
impl LingeringClose
pub const fn new() -> LingeringClose
pub const fn new() -> LingeringClose
Linger while data keeps arriving within 2 seconds, for at most 30 seconds in total, without a byte limit.
pub fn with_idle_timeout(self, timeout: Duration) -> LingeringClose
pub fn with_idle_timeout(self, timeout: Duration) -> LingeringClose
Stop lingering once nothing arrived for this long. If this is at least the total timeout, the total limit wins instead. HTTP/1 servers can then abort a blocked response even for an idle client.
pub fn set_idle_timeout(&mut self, timeout: Duration) -> &mut LingeringClose
pub fn set_idle_timeout(&mut self, timeout: Duration) -> &mut LingeringClose
Stop lingering once nothing arrived for this long. If this is at least the total timeout, the total limit wins instead. HTTP/1 servers can then abort a blocked response even for an idle client.
pub fn with_timeout(self, timeout: Duration) -> LingeringClose
pub fn with_timeout(self, timeout: Duration) -> LingeringClose
Stop lingering once this long passed in total.
pub fn set_timeout(&mut self, timeout: Duration) -> &mut LingeringClose
pub fn set_timeout(&mut self, timeout: Duration) -> &mut LingeringClose
Stop lingering once this long passed in total.
pub fn maybe_with_max_bytes(self, max: Option<u64>) -> LingeringClose
pub fn maybe_with_max_bytes(self, max: Option<u64>) -> LingeringClose
Stop lingering once this many bytes were read and discarded.
None (the default) sets no limit.
pub fn maybe_set_max_bytes(&mut self, max: Option<u64>) -> &mut LingeringClose
pub fn maybe_set_max_bytes(&mut self, max: Option<u64>) -> &mut LingeringClose
Stop lingering once this many bytes were read and discarded.
None (the default) sets no limit.
pub fn with_max_bytes(self, max: u64) -> LingeringClose
pub fn with_max_bytes(self, max: u64) -> LingeringClose
Stop lingering once this many bytes were read and discarded.
None (the default) sets no limit.
pub fn set_max_bytes(&mut self, max: u64) -> &mut LingeringClose
pub fn set_max_bytes(&mut self, max: u64) -> &mut LingeringClose
Stop lingering once this many bytes were read and discarded.
None (the default) sets no limit.
pub fn without_max_bytes(self) -> LingeringClose
pub fn without_max_bytes(self) -> LingeringClose
Stop lingering once this many bytes were read and discarded.
None (the default) sets no limit.
pub fn unset_max_bytes(&mut self) -> &mut LingeringClose
pub fn unset_max_bytes(&mut self) -> &mut LingeringClose
Stop lingering once this many bytes were read and discarded.
None (the default) sets no limit.
pub const fn idle_timeout(&self) -> Duration
pub const fn idle_timeout(&self) -> Duration
How long a lingering connection waits for more data.
pub const fn max_bytes(&self) -> Option<u64>
pub const fn max_bytes(&self) -> Option<u64>
How many bytes a connection reads and discards at most while lingering, if limited.
pub const fn is_enabled(&self) -> bool
pub const fn is_enabled(&self) -> bool
Whether these bounds let a connection linger at all.
Trait Implementations§
§impl Clone for LingeringClose
impl Clone for LingeringClose
§fn clone(&self) -> LingeringClose
fn clone(&self) -> LingeringClose
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreimpl Copy for LingeringClose
§impl Debug for LingeringClose
impl Debug for LingeringClose
§impl Default for LingeringClose
impl Default for LingeringClose
§fn default() -> LingeringClose
fn default() -> LingeringClose
impl Eq for LingeringClose
§impl PartialEq for LingeringClose
impl PartialEq for LingeringClose
impl StructuralPartialEq for LingeringClose
Auto Trait Implementations§
impl Freeze for LingeringClose
impl RefUnwindSafe for LingeringClose
impl Send for LingeringClose
impl Sync for LingeringClose
impl Unpin for LingeringClose
impl UnsafeUnpin for LingeringClose
impl UnwindSafe for LingeringClose
Blanket Implementations§
§impl<'a, T, E> AsTaggedExplicit<'a, E> for Twhere
T: 'a,
impl<'a, T, E> AsTaggedExplicit<'a, E> for Twhere
T: 'a,
§impl<'a, T, E> AsTaggedImplicit<'a, E> for Twhere
T: 'a,
impl<'a, T, E> AsTaggedImplicit<'a, E> for Twhere
T: 'a,
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
key and return true if they are equal.§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
§impl<T> FutureExt for T
impl<T> FutureExt for T
§fn with_context(self, otel_cx: Context) -> WithContext<Self> ⓘ
fn with_context(self, otel_cx: Context) -> WithContext<Self> ⓘ
§fn with_current_context(self) -> WithContext<Self> ⓘ
fn with_current_context(self) -> WithContext<Self> ⓘ
§impl<T> Instrument for T
impl<T> Instrument for T
§fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
§fn in_current_span(self) -> Instrumented<Self> ⓘ
fn in_current_span(self) -> Instrumented<Self> ⓘ
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more§impl<T> IntoRequest<T> for T
impl<T> IntoRequest<T> for T
§fn into_request(self) -> Request<T>
fn into_request(self) -> Request<T>
T in a rama_grpc::Request§impl<T> Pointable for T
impl<T> Pointable for T
§impl<T> PolicyExt for Twhere
T: ?Sized,
impl<T> PolicyExt for Twhere
T: ?Sized,
§fn and<P, B, E>(self, other: P) -> And<T, P>
fn and<P, B, E>(self, other: P) -> And<T, P>
Policy that returns Action::Follow only if self and other return
Action::Follow. Read more