Skip to content

Commit

Permalink
Improve docs for tag mismatch
Browse files Browse the repository at this point in the history
  • Loading branch information
jonhoo committed Mar 31, 2024
1 parent af5ad73 commit ed433ec
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 4 deletions.
11 changes: 8 additions & 3 deletions src/client.rs
Original file line number Diff line number Diff line change
Expand Up @@ -176,9 +176,14 @@ pub struct Connection<T: Read + Write> {
impl<T: Read + Write> Connection<T> {
/// Manually increment the current tag.
///
/// This function can be manually executed by callers when the
/// previous tag was not reused, for example when a timeout did
/// not write anything on the stream.
/// If writing a command to the server fails, [`Client`] assumes that the command did not reach
/// the server, and thus that the next tag that should be sent is still the one used for the
/// failed command. However, it could be the case that the command _did_ reach the server
/// before failing, and thus a fresh tag needs to be issued instead.
///
/// This function can be used to attempt to manually re-synchronize the client's tag tracker in
/// such cases. It forcibly increments the client's tag counter such that the next command
/// sent to the server will have a tag that is one greater than it otherwise would.
pub fn skip_tag(&mut self) {
self.tag += 1;
}
Expand Down
3 changes: 2 additions & 1 deletion src/error.rs
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,8 @@ pub enum Error {
MissingStatusResponse,
/// The server responded with a different command tag than the one we just sent.
///
/// A new session must generally be established to recover from this.
/// A new session must generally be established to recover from this. You can also use
/// [`Connection::skip_tag`] (which is available through both [`Client`] and [`Session`]).
TagMismatch(TagMismatch),
/// StartTls is not available on the server
StartTlsNotAvailable,
Expand Down

0 comments on commit ed433ec

Please sign in to comment.