pub struct BroadcastChannel { /* private fields */ }Expand description
A handle to a named broadcast channel.
Obtain one via [Broadcasting::channel], [Broadcasting::private_channel],
or [Broadcasting::presence_channel].
Implementations§
Source§impl BroadcastChannel
impl BroadcastChannel
pub fn new( name: String, kind: ChannelKind, driver: Arc<dyn BroadcastDriver>, ) -> Self
Sourcepub fn to_user(self, user_id: impl ToString) -> Self
pub fn to_user(self, user_id: impl ToString) -> Self
Scope the emission to a specific user’s channel ({name}.{user_id}).
Sourcepub async fn emit<T: Serialize>(
&self,
event: impl Into<String>,
data: &T,
) -> Result<(), BroadcastError>
pub async fn emit<T: Serialize>( &self, event: impl Into<String>, data: &T, ) -> Result<(), BroadcastError>
Emit an event with a serializable payload.
Sourcepub async fn emit_raw(
&self,
event: impl Into<String>,
data: Value,
) -> Result<(), BroadcastError>
pub async fn emit_raw( &self, event: impl Into<String>, data: Value, ) -> Result<(), BroadcastError>
Emit a raw JSON value.
pub fn kind(&self) -> ChannelKind
pub fn name(&self) -> &str
Auto Trait Implementations§
impl Freeze for BroadcastChannel
impl !RefUnwindSafe for BroadcastChannel
impl Send for BroadcastChannel
impl Sync for BroadcastChannel
impl Unpin for BroadcastChannel
impl UnsafeUnpin for BroadcastChannel
impl !UnwindSafe for BroadcastChannel
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