Skip to content

Commit

Permalink
move the Action enum declaration outside the loop
Browse files Browse the repository at this point in the history
  • Loading branch information
vilgotf committed Jun 24, 2023
1 parent e4829a5 commit 90422cb
Showing 1 changed file with 14 additions and 13 deletions.
27 changes: 14 additions & 13 deletions twilight-gateway/src/shard.rs
Original file line number Diff line number Diff line change
Expand Up @@ -577,20 +577,21 @@ impl Shard {
_ => {}
}

/// Actions the shard might take.
enum Action {
/// Close the gateway connection with this close frame.
Close(CloseFrame<'static>),
/// Send this command to the gateway.
Command(String),
/// Send a heartbeat command to the gateway.
Heartbeat,
/// Identify with the gateway.
Identify,
/// Handle this incoming gateway message.
Message(Option<Result<TungsteniteMessage, TungsteniteError>>),
}

let message = loop {
/// Actions the shard might take.
enum Action {
/// Close the gateway connection with this close frame.
Close(CloseFrame<'static>),
/// Send this command to the gateway.
Command(String),
/// Send a heartbeat command to the gateway.
Heartbeat,
/// Identify with the gateway.
Identify,
/// Handle this incoming gateway message.
Message(Option<Result<TungsteniteMessage, TungsteniteError>>),
}
let next_action = |cx: &mut Context<'_>| {
if !(self.status.is_disconnected() || self.status.is_fatally_closed()) {
if let Poll::Ready(frame) = self.user_channel.close_rx.poll_recv(cx) {
Expand Down

0 comments on commit 90422cb

Please sign in to comment.