pub struct MessageSender { /* private fields */ }
Expand description
Channel to send messages over a Shard
to the Discord gateway.
Implementations§
Source§impl MessageSender
impl MessageSender
Sourcepub fn is_closed(&self) -> bool
pub fn is_closed(&self) -> bool
Whether the channel is closed.
The channel will only be closed if the associated shard has been dropped.
Sourcepub fn command(&self, command: &impl Command) -> Result<(), ChannelError>
pub fn command(&self, command: &impl Command) -> Result<(), ChannelError>
Send a command to the associated shard.
§Errors
Returns a ChannelErrorType::Closed
error type if the channel is
closed.
Sourcepub fn send(&self, json: String) -> Result<(), ChannelError>
pub fn send(&self, json: String) -> Result<(), ChannelError>
Send a JSON encoded gateway event to the associated shard.
§Errors
Returns a ChannelErrorType::Closed
error type if the channel is
closed.
Sourcepub fn close(
&self,
close_frame: CloseFrame<'static>,
) -> Result<(), ChannelError>
pub fn close( &self, close_frame: CloseFrame<'static>, ) -> Result<(), ChannelError>
Send a Websocket close frame to the associated shard.
Subsequent calls may be queued up to be sent once the shard’s
reestablished a Websocket connection or ignored if the queue is full.
The internal queue capacity is currently 1
.
See the Shard::close
docs for further information.
§Errors
Returns a ChannelErrorType::Closed
error type if the channel is
closed.
Trait Implementations§
Source§impl Clone for MessageSender
impl Clone for MessageSender
Source§fn clone(&self) -> MessageSender
fn clone(&self) -> MessageSender
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source
. Read more