pub struct BodyGuard<B> { /* private fields */ }Expand description
A body wrapped with explicit lifecycle policy.
Implementations§
Source§impl<B> BodyGuard<B>
impl<B> BodyGuard<B>
Sourcepub fn with_policy(inner: B, policy: BodyPolicy) -> Self
pub fn with_policy(inner: B, policy: BodyPolicy) -> Self
Create a new guarded body with an explicit policy.
Sourcepub fn overflow(self, policy: OverflowPolicy) -> Self
pub fn overflow(self, policy: OverflowPolicy) -> Self
Set overflow behavior.
Sourcepub fn drop_policy(self, policy: DropPolicy) -> Self
pub fn drop_policy(self, policy: DropPolicy) -> Self
Set drop behavior.
Sourcepub fn drain_policy(self, policy: DrainPolicy) -> Self
pub fn drain_policy(self, policy: DrainPolicy) -> Self
Set drain behavior.
Sourcepub fn replay_policy(self, policy: ReplayPolicy) -> Self
pub fn replay_policy(self, policy: ReplayPolicy) -> Self
Set replay behavior.
Sourcepub fn shutdown_policy(self, policy: ShutdownPolicy) -> Self
pub fn shutdown_policy(self, policy: ShutdownPolicy) -> Self
Set shutdown behavior.
Sourcepub fn policy(&self) -> &BodyPolicy
pub fn policy(&self) -> &BodyPolicy
Return the configured policy.
Sourcepub fn bytes_seen(&self) -> u64
pub fn bytes_seen(&self) -> u64
Return the number of bytes observed through this guard.
Sourcepub fn mark_pending(&mut self)
pub fn mark_pending(&mut self)
Mark the body as waiting for an underlying body or stream to become ready.
Sourcepub fn mark_reading(&mut self)
pub fn mark_reading(&mut self)
Mark the body as currently being read.
Sourcepub fn mark_draining(&mut self)
pub fn mark_draining(&mut self)
Mark the body as draining.
Sourcepub fn mark_completed(&mut self)
pub fn mark_completed(&mut self)
Mark the body as completed.
Sourcepub fn mark_aborted(&mut self)
pub fn mark_aborted(&mut self)
Mark the body as aborted.
Sourcepub fn observe_bytes(&mut self, bytes: u64) -> BodyDecision
pub fn observe_bytes(&mut self, bytes: u64) -> BodyDecision
Record newly observed bytes and return the policy decision.
Sourcepub fn into_inner(self) -> B
pub fn into_inner(self) -> B
Consume the guard and return the inner body.
Trait Implementations§
Auto Trait Implementations§
impl<B> Freeze for BodyGuard<B>where
B: Freeze,
impl<B> RefUnwindSafe for BodyGuard<B>where
B: RefUnwindSafe,
impl<B> Send for BodyGuard<B>where
B: Send,
impl<B> Sync for BodyGuard<B>where
B: Sync,
impl<B> Unpin for BodyGuard<B>where
B: Unpin,
impl<B> UnsafeUnpin for BodyGuard<B>where
B: UnsafeUnpin,
impl<B> UnwindSafe for BodyGuard<B>where
B: UnwindSafe,
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