pub struct MessageChannel { /* private fields */ }Expand description
实时消息通道。Clone 即克隆底层 sender,可多生产者并发推送。
Implementations§
Source§impl MessageChannel
impl MessageChannel
Sourcepub fn new() -> (Self, UnboundedReceiver<AgentMessage>)
pub fn new() -> (Self, UnboundedReceiver<AgentMessage>)
创建通道,返回 (channel, receiver)。所有 channel 副本 drop 后,receiver 收到 None。
Sourcepub fn disconnected() -> Self
pub fn disconnected() -> Self
一个没有消费者的通道:send 全部静默丢弃。未配置 messages 时的默认值。
Sourcepub fn send(&self, session_id: &str, kind: MessageKind)
pub fn send(&self, session_id: &str, kind: MessageKind)
投递一条消息。fire-and-forget:消费者已断开则静默丢弃,不阻断主流程。
Trait Implementations§
Source§impl Clone for MessageChannel
impl Clone for MessageChannel
Source§fn clone(&self) -> MessageChannel
fn clone(&self) -> MessageChannel
Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source. Read moreAuto Trait Implementations§
impl Freeze for MessageChannel
impl RefUnwindSafe for MessageChannel
impl Send for MessageChannel
impl Sync for MessageChannel
impl Unpin for MessageChannel
impl UnsafeUnpin for MessageChannel
impl UnwindSafe for MessageChannel
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