pub trait HasPayload {
type Payload: Payload;
// Required methods
fn payload_mut(&mut self) -> &mut Self::Payload;
fn payload_ref(&self) -> &Self::Payload;
// Provided method
fn with_payload_mut<F>(self, f: F) -> Self
where Self: Sized,
F: FnOnce(&mut Self::Payload) { ... }
}Expand description
Represents types having payload inside.
This trait is something between DerefMut and BorrowMut — it allows
only one implementation per type (the output type is associated, not
generic), has implementations for all types P such P: Payload, but
has no magic compiler support like DerefMut does nor does it require
any laws about Eq, Ord and Hash as BorrowMut does.
Also the output type is bounded by the Payload trait.
This trait is mostly used to implement payload setters (on both payloads & requests), so you probably won’t find yourself using it directly.
Required Associated Types§
Required Methods§
Sourcefn payload_mut(&mut self) -> &mut Self::Payload
fn payload_mut(&mut self) -> &mut Self::Payload
Gain mutable access to the underlying payload.
Sourcefn payload_ref(&self) -> &Self::Payload
fn payload_ref(&self) -> &Self::Payload
Gain immutable access to the underlying payload.
Provided Methods§
Sourcefn with_payload_mut<F>(self, f: F) -> Self
fn with_payload_mut<F>(self, f: F) -> Self
Update payload with a function
Dyn Compatibility§
This trait is dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety".
Implementations on Foreign Types§
Source§impl<L, R> HasPayload for Either<L, R>
impl<L, R> HasPayload for Either<L, R>
type Payload = <L as HasPayload>::Payload
fn payload_mut(&mut self) -> &mut Self::Payload
fn payload_ref(&self) -> &Self::Payload
Implementors§
Source§impl<P> HasPayload for JsonRequest<P>where
P: Payload,
impl<P> HasPayload for JsonRequest<P>where
P: Payload,
Source§impl<P> HasPayload for MultipartRequest<P>where
P: Payload,
impl<P> HasPayload for MultipartRequest<P>where
P: Payload,
Source§impl<R: HasPayload + Clone> HasPayload for ThrottlingRequest<R>
Available on crate feature throttle only.
impl<R: HasPayload + Clone> HasPayload for ThrottlingRequest<R>
throttle only.type Payload = <R as HasPayload>::Payload
Source§impl<R: Request<Payload = GetMe>> HasPayload for CachedMeRequest<R>
Available on crate feature cache_me only.
impl<R: Request<Payload = GetMe>> HasPayload for CachedMeRequest<R>
cache_me only.Source§impl<R> HasPayload for TraceRequest<R>where
R: HasPayload,
Available on crate feature trace_adaptor only.
impl<R> HasPayload for TraceRequest<R>where
R: HasPayload,
trace_adaptor only.type Payload = <R as HasPayload>::Payload
Source§impl<T, E> HasPayload for ErasedRequest<'_, T, E>where
T: Payload,
Available on crate feature erased only.
impl<T, E> HasPayload for ErasedRequest<'_, T, E>where
T: Payload,
erased only.