pub struct BroadcastResponse<T>(/* private fields */)
where
T: Clone;
Expand description
Variation of AsyncResponse
that efficiently broadcasts responses to many requests.
This response behavior is useful for services that cache or debounce requests. Instead of
responding to each equivalent request via its individual sender, the broadcast behavior allows
to create a BroadcastChannel
that efficiently resolves all pending requests once the value
is ready.
Similar to AsyncResponse
, the service receives a sender that it can use to send a value
directly back to the waiting request. Additionally, the sender can be converted into a channel
or attached to an already existing channel, if the service expects more requests while computing
the response.
See FromMessage
and Service
for implementation advice and examples.
Trait Implementations§
source§impl<T: Clone> Debug for BroadcastResponse<T>
impl<T: Clone> Debug for BroadcastResponse<T>
source§impl<T: Clone> MessageResponse for BroadcastResponse<T>
impl<T: Clone> MessageResponse for BroadcastResponse<T>
source§type Sender = BroadcastSender<T>
type Sender = BroadcastSender<T>
Sends responses from the service back to the waiting recipient.
source§type Output = BroadcastRequest<T>
type Output = BroadcastRequest<T>
The type returned from
Addr::send
. Read moreAuto Trait Implementations§
impl<T> Freeze for BroadcastResponse<T>
impl<T> RefUnwindSafe for BroadcastResponse<T>where
T: RefUnwindSafe,
impl<T> Send for BroadcastResponse<T>where
T: Send,
impl<T> Sync for BroadcastResponse<T>where
T: Sync,
impl<T> Unpin for BroadcastResponse<T>where
T: Unpin,
impl<T> UnwindSafe for BroadcastResponse<T>where
T: 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