pub struct RequestGuard { /* private fields */ }core only.Expand description
A single-use capability token proving the holder owns the current request.
Created by QueryResource::accept_current_request, consumed by one of the
complete_* methods. The guard is moved (not copied) into the
completion method, which enforces the two-phase protocol at the type level:
once a guard is used, it cannot be used again.
§Two-phase protocol
- Accept:
resource.accept_current_request(request_id)validates that the request is still active and returnsSome(RequestGuard). - Complete:
resource.complete_success(guard, data, now_ms)consumes the guard and applies the result. Attempting to use the guard again is a compile error because it has been moved.
§Why not Copy?
Previous versions derived Clone + Copy, which allowed the same guard to
be passed to multiple complete_* calls. While the second call would be a
no-op (the resource already cleared active_request_id), it was wasteful
and could mask bugs. Taking the guard by value prevents this entirely.
Implementations§
Source§impl RequestGuard
impl RequestGuard
Sourcepub fn request_id(&self) -> RequestId
pub fn request_id(&self) -> RequestId
The request id this guard protects (borrowed).
Sourcepub fn into_request_id(self) -> RequestId
pub fn into_request_id(self) -> RequestId
Consume the guard and return the request id.
Useful when you want to extract the id and discard the guard.
Trait Implementations§
Source§impl Debug for RequestGuard
impl Debug for RequestGuard
impl Eq for RequestGuard
Source§impl PartialEq for RequestGuard
impl PartialEq for RequestGuard
impl StructuralPartialEq for RequestGuard
Auto Trait Implementations§
impl Freeze for RequestGuard
impl RefUnwindSafe for RequestGuard
impl Send for RequestGuard
impl Sync for RequestGuard
impl Unpin for RequestGuard
impl UnsafeUnpin for RequestGuard
impl UnwindSafe for RequestGuard
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
impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
Source§impl<T> Downcast for Twhere
T: Any,
impl<T> Downcast for Twhere
T: Any,
Source§fn into_any(self: Box<T>) -> Box<dyn Any>
fn into_any(self: Box<T>) -> Box<dyn Any>
Box<dyn Trait> (where Trait: Downcast) to Box<dyn Any>. Box<dyn Any> can
then be further downcast into Box<ConcreteType> where ConcreteType implements Trait.Source§fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
Rc<Trait> (where Trait: Downcast) to Rc<Any>. Rc<Any> can then be
further downcast into Rc<ConcreteType> where ConcreteType implements Trait.Source§fn as_any(&self) -> &(dyn Any + 'static)
fn as_any(&self) -> &(dyn Any + 'static)
&Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot
generate &Any’s vtable from &Trait’s.Source§fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
&mut Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot
generate &mut Any’s vtable from &mut Trait’s.Source§impl<T> DowncastSync for T
impl<T> DowncastSync for T
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
key and return true if they are equal.Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
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> ⓘ
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