Use next_id instead of last_id
This commit is contained in:
parent
f093c0e9e5
commit
17ff660ab2
1 changed files with 4 additions and 5 deletions
|
|
@ -76,7 +76,7 @@ pub struct ClientConn {
|
||||||
conn: Conn,
|
conn: Conn,
|
||||||
state: State,
|
state: State,
|
||||||
|
|
||||||
last_id: usize,
|
next_id: usize,
|
||||||
replies: Replies<String, ParsedPacket>,
|
replies: Replies<String, ParsedPacket>,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -135,9 +135,8 @@ impl ClientConn {
|
||||||
/// A packet id is automatically generated and returned. When the server
|
/// A packet id is automatically generated and returned. When the server
|
||||||
/// replies to the packet, it will use this id as its [`ParsedPacket::id`].
|
/// replies to the packet, it will use this id as its [`ParsedPacket::id`].
|
||||||
pub async fn send(&mut self, data: impl Into<Data>) -> Result<String> {
|
pub async fn send(&mut self, data: impl Into<Data>) -> Result<String> {
|
||||||
// Overkill of universe-heat-death-like proportions
|
let id = self.next_id.to_string();
|
||||||
self.last_id = self.last_id.wrapping_add(1);
|
self.next_id += 1;
|
||||||
let id = self.last_id.to_string();
|
|
||||||
|
|
||||||
self.conn
|
self.conn
|
||||||
.send(ParsedPacket::from_data(Some(id.clone()), data.into()))
|
.send(ParsedPacket::from_data(Some(id.clone()), data.into()))
|
||||||
|
|
@ -252,7 +251,7 @@ impl ClientConn {
|
||||||
tx,
|
tx,
|
||||||
conn,
|
conn,
|
||||||
state: State::new(),
|
state: State::new(),
|
||||||
last_id: 0,
|
next_id: 0,
|
||||||
replies: Replies::new(config.command_timeout),
|
replies: Replies::new(config.command_timeout),
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue