Trait teloxide::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