Trait teloxide_core::requests::HasPayload
source · 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) -> Selfwhere
Self: Sized,
F: FnOnce(&mut Self::Payload),
fn with_payload_mut<F>(self, f: F) -> Selfwhere Self: Sized, F: FnOnce(&mut Self::Payload),
Update payload with a function
Implementations on Foreign Types§
source§impl<L, R> HasPayload for Either<L, R>where
L: HasPayload,
R: HasPayload<Payload = L::Payload>,
impl<L, R> HasPayload for Either<L, R>where L: HasPayload, R: HasPayload<Payload = L::Payload>,
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 for TraceRequest<R>where
R: HasPayload,
Available on crate feature trace_adaptor
only.
impl<R> HasPayload for TraceRequest<R>where R: HasPayload,
Available on crate feature
trace_adaptor
only.type Payload = <R as HasPayload>::Payload
source§impl<R: HasPayload + Clone> HasPayload for ThrottlingRequest<R>
Available on crate feature throttle
only.
impl<R: HasPayload + Clone> HasPayload for ThrottlingRequest<R>
Available on crate feature
throttle
only.type Payload = <R as HasPayload>::Payload
source§impl<R: Request> HasPayload for AutoRequest<R>
Available on crate feature auto_send
only.
impl<R: Request> HasPayload for AutoRequest<R>
Available on crate feature
auto_send
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>
Available on crate feature
cache_me
only.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,
Available on crate feature
erased
only.