From 17ff660ab2bc5ba5954a85e16c5242c2f0a5efd7 Mon Sep 17 00:00:00 2001 From: Joscha Date: Fri, 27 Dec 2024 14:28:18 +0100 Subject: [PATCH] Use next_id instead of last_id --- euphoxide/src/client/conn.rs | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/euphoxide/src/client/conn.rs b/euphoxide/src/client/conn.rs index 5f39d63..a178b4c 100644 --- a/euphoxide/src/client/conn.rs +++ b/euphoxide/src/client/conn.rs @@ -76,7 +76,7 @@ pub struct ClientConn { conn: Conn, state: State, - last_id: usize, + next_id: usize, replies: Replies, } @@ -135,9 +135,8 @@ impl ClientConn { /// A packet id is automatically generated and returned. When the server /// replies to the packet, it will use this id as its [`ParsedPacket::id`]. pub async fn send(&mut self, data: impl Into) -> Result { - // Overkill of universe-heat-death-like proportions - self.last_id = self.last_id.wrapping_add(1); - let id = self.last_id.to_string(); + let id = self.next_id.to_string(); + self.next_id += 1; self.conn .send(ParsedPacket::from_data(Some(id.clone()), data.into())) @@ -252,7 +251,7 @@ impl ClientConn { tx, conn, state: State::new(), - last_id: 0, + next_id: 0, replies: Replies::new(config.command_timeout), };