Struct twilight_gateway::MessageSender
source · 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