pub struct RelaySender { /* private fields */ }Expand description
The single owner of a relay channel.
This type is intentionally not Clone. There is exactly one owner
of a channel, and when this owner is dropped, the channel closes.
Use weak() to create WeakSender handles that can send messages
without keeping the channel alive.
Implementations§
Source§impl RelaySender
impl RelaySender
Sourcepub async fn send<T: 'static + Send + Sync>(
&self,
value: T,
) -> Result<(), SendError>
pub async fn send<T: 'static + Send + Sync>( &self, value: T, ) -> Result<(), SendError>
Send a typed message to all subscribers.
Sourcepub async fn send_any(
&self,
value: Arc<dyn Any + Send + Sync>,
type_id: TypeId,
) -> Result<(), SendError>
pub async fn send_any( &self, value: Arc<dyn Any + Send + Sync>, type_id: TypeId, ) -> Result<(), SendError>
Send a type-erased message.
Sourcepub async fn send_any_with_origin(
&self,
value: Arc<dyn Any + Send + Sync>,
type_id: TypeId,
origin: u64,
) -> Result<(), SendError>
pub async fn send_any_with_origin( &self, value: Arc<dyn Any + Send + Sync>, type_id: TypeId, origin: u64, ) -> Result<(), SendError>
Send a type-erased message with a specific origin (for echo prevention).
Sourcepub async fn send_envelope(&self, envelope: Envelope) -> Result<(), SendError>
pub async fn send_envelope(&self, envelope: Envelope) -> Result<(), SendError>
Send a pre-constructed envelope. Used for advanced scenarios like forwarding.
Sourcepub fn weak(&self) -> WeakSender
pub fn weak(&self) -> WeakSender
Create a weak sender handle.
Weak senders can send messages but don’t keep the channel alive. Use this for background tasks that should exit when the owner drops.
Sourcepub fn handler_count(&self) -> usize
pub fn handler_count(&self) -> usize
Get the current handler count for this relay.
Trait Implementations§
Auto Trait Implementations§
impl Freeze for RelaySender
impl !RefUnwindSafe for RelaySender
impl Send for RelaySender
impl Sync for RelaySender
impl Unpin for RelaySender
impl !UnwindSafe for RelaySender
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