pub struct UploadGuard { /* private fields */ }Expand description
Runtime guard built from ServerLimits, shared across requests as an axum
extension. Holds the concurrency semaphore (if any) and the per-upload caps.
Implementations§
Source§impl UploadGuard
impl UploadGuard
Sourcepub fn new(limits: ServerLimits) -> Self
pub fn new(limits: ServerLimits) -> Self
Build a guard from limits (an unbounded guard if limits.is_unlimited()).
Sourcepub fn try_acquire(&self) -> Option<UploadPermit>
pub fn try_acquire(&self) -> Option<UploadPermit>
Try to claim an upload slot. Some (held for the upload’s duration) when
admitted — including the unlimited case; None when the concurrency cap
is currently saturated.
Sourcepub fn content_length_rejected(&self, content_length: Option<u64>) -> bool
pub fn content_length_rejected(&self, content_length: Option<u64>) -> bool
Whether content_length already exceeds the size cap (cheap early 413).
Sourcepub fn limit_body(&self, stream: ByteStream) -> ByteStream
pub fn limit_body(&self, stream: ByteStream) -> ByteStream
Wrap an upload body so it is aborted if it exceeds the size cap or stalls past the idle timeout. A no-op (returns the stream unchanged) when neither applies, so the unlimited path keeps zero overhead.
Trait Implementations§
Source§impl Clone for UploadGuard
impl Clone for UploadGuard
Source§fn clone(&self) -> UploadGuard
fn clone(&self) -> UploadGuard
Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source. Read moreAuto Trait Implementations§
impl Freeze for UploadGuard
impl RefUnwindSafe for UploadGuard
impl Send for UploadGuard
impl Sync for UploadGuard
impl Unpin for UploadGuard
impl UnsafeUnpin for UploadGuard
impl UnwindSafe for UploadGuard
Blanket Implementations§
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
Mutably borrows from an owned value. Read more
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<A, B, T> HttpServerConnExec<A, B> for Twhere
B: Body,
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
Source§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> ⓘ
Converts
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> ⓘ
Converts
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