fn add_labels_and_update_pin(
        &mut self,
        conn: Option<&Connection>,
        session: &mut Option<&mut ClientSession>,
        retryability: Option<&Retryability>,
    ) -> Result<()> {
        let transaction_state = session.as_ref().map_or(&TransactionState::None, |session| {
            &session.transaction.state
        });
        let max_wire_version = if let Some(conn) = conn {
            conn.stream_description()?.max_wire_version
        } else {
            None
        };
        match transaction_state {
            TransactionState::Starting | TransactionState::InProgress => {
                if self.is_network_error() || self.is_server_selection_error() {
                    self.add_label(TRANSIENT_TRANSACTION_ERROR);
                }
            }
            TransactionState::Committed { .. } => {
                if let Some(max_wire_version) = max_wire_version {
                    if self.should_add_retryable_write_label(max_wire_version) {
                        self.add_label(RETRYABLE_WRITE_ERROR);
                    }
                }
                if self.should_add_unknown_transaction_commit_result_label() {
                    self.add_label(UNKNOWN_TRANSACTION_COMMIT_RESULT);
                }
            }
            TransactionState::Aborted => {
                if let Some(max_wire_version) = max_wire_version {
                    if self.should_add_retryable_write_label(max_wire_version) {
                        self.add_label(RETRYABLE_WRITE_ERROR);
                    }
                }
            }
            TransactionState::None => {
                if retryability == Some(&Retryability::Write) {
                    if let Some(max_wire_version) = max_wire_version {
                        if self.should_add_retryable_write_label(max_wire_version) {
                            self.add_label(RETRYABLE_WRITE_ERROR);
                        }
                    }
                }
            }
        }

        if let Some(ref mut session) = session {
            if self.contains_label(TRANSIENT_TRANSACTION_ERROR)
                || self.contains_label(UNKNOWN_TRANSACTION_COMMIT_RESULT)
            {
                session.unpin();
            }
        }

        Ok(())
    }
/// Adds the necessary labels to this Error, and unpins the session if needed.
///
/// A TransientTransactionError label should be added if a transaction is in progress and the
/// error is a network or server selection error.
///
/// On a pre-4.4 connection, a RetryableWriteError label should be added to any write-retryable
/// error. On a 4.4+ connection, a label should only be added to network errors. Regardless of
/// server version, a label should only be added if the `retry_writes` client option is not set
/// to `false`, the operation during which the error occured is write-retryable, and a
/// TransientTransactionError label has not already been added.
///
/// If the TransientTransactionError or UnknownTransactionCommitResult labels are added, the
/// ClientSession should be unpinned.
Adds the necessary labels to this Error, and unpins the session if needed.
A TransientTransactionError label should be added if a transaction is in progress and the
error is a network or server selection error.

On a pre-4.4 connection, a RetryableWriteError label should be added to any write-retryable
error. On a 4.4+ connection, a label should only be added to network errors. Regardless of
server version, a label should only be added if the `retry_writes` client option is not set
to `false`, the operation during which the error occured is write-retryable, and a
TransientTransactionError label has not already been added.

If the TransientTransactionError or UnknownTransactionCommitResult labels are added, the
ClientSession should be unpinned.
Adds the necessary labels to this Error and unpins the session if needed . A TransientTransactionError label should be added if a transaction is in progress and the error is a network or server selection error . On a pre - 4 . 4 connection a RetryableWriteError label should be added to any write - retryable error . On a 4 . 4 + connection a label should only be added to network errors . Regardless of server version a label should only be added if the ` retry_writes ` client option is not set to ` false ` the operation during which the error occured is write - retryable and a TransientTransactionError label has not already been added . If the TransientTransactionError or UnknownTransactionCommitResult labels are added the ClientSession should be unpinned .
fn add_labels_and_update_pin(
        &mut self,
        conn: Option<&Connection>,
        session: &mut Option<&mut ClientSession>,
        retryability: Option<&Retryability>,
    ) -> Result<()> {
        let transaction_state = session.as_ref().map_or(&TransactionState::None, |session| {
            &session.transaction.state
        });
        let max_wire_version = if let Some(conn) = conn {
            conn.stream_description()?.max_wire_version
        } else {
            None
        };
        match transaction_state {
            TransactionState::Starting | TransactionState::InProgress => {
                if self.is_network_error() || self.is_server_selection_error() {
                    self.add_label(TRANSIENT_TRANSACTION_ERROR);
                }
            }
            TransactionState::Committed { .. } => {
                if let Some(max_wire_version) = max_wire_version {
                    if self.should_add_retryable_write_label(max_wire_version) {
                        self.add_label(RETRYABLE_WRITE_ERROR);
                    }
                }
                if self.should_add_unknown_transaction_commit_result_label() {
                    self.add_label(UNKNOWN_TRANSACTION_COMMIT_RESULT);
                }
            }
            TransactionState::Aborted => {
                if let Some(max_wire_version) = max_wire_version {
                    if self.should_add_retryable_write_label(max_wire_version) {
                        self.add_label(RETRYABLE_WRITE_ERROR);
                    }
                }
            }
            TransactionState::None => {
                if retryability == Some(&Retryability::Write) {
                    if let Some(max_wire_version) = max_wire_version {
                        if self.should_add_retryable_write_label(max_wire_version) {
                            self.add_label(RETRYABLE_WRITE_ERROR);
                        }
                    }
                }
            }
        }
        if let Some(ref mut session) = session {
            if self.contains_label(TRANSIENT_TRANSACTION_ERROR)
                || self.contains_label(UNKNOWN_TRANSACTION_COMMIT_RESULT)
            {
                session.unpin();
            }
        }
        Ok(())
    }
fn add_labels_and_update_pin ( & mut self , conn : Option < & Connection > , session : & mut Option < & mut ClientSession > , retryability : Option < & Retryability > , ) -> Result < ( ) > { let transaction_state = session . as_ref ( ) . map_or ( & TransactionState :: None , | session | { & session . transaction . state } ) ; let max_wire_version = if let Some ( conn ) = conn { conn . stream_description ( ) ? . max_wire_version } else { None } ; match transaction_state { TransactionState :: Starting | TransactionState :: InProgress => { if self . is_network_error ( ) || self . is_server_selection_error ( ) { self . add_label ( TRANSIENT_TRANSACTION_ERROR ) ; } } TransactionState :: Committed { .. } => { if let Some ( max_wire_version ) = max_wire_version { if self . should_add_retryable_write_label ( max_wire_version ) { self . add_label ( RETRYABLE_WRITE_ERROR ) ; } } if self . should_add_unknown_transaction_commit_result_label ( ) { self . add_label ( UNKNOWN_TRANSACTION_COMMIT_RESULT ) ; } } TransactionState :: Aborted => { if let Some ( max_wire_version ) = max_wire_version { if self . should_add_retryable_write_label ( max_wire_version ) { self . add_label ( RETRYABLE_WRITE_ERROR ) ; } } } TransactionState :: None => { if retryability == Some ( & Retryability :: Write ) { if let Some ( max_wire_version ) = max_wire_version { if self . should_add_retryable_write_label ( max_wire_version ) { self . add_label ( RETRYABLE_WRITE_ERROR ) ; } } } } } if let Some ( ref mut session ) = session { if self . contains_label ( TRANSIENT_TRANSACTION_ERROR ) || self . contains_label ( UNKNOWN_TRANSACTION_COMMIT_RESULT ) { session . unpin ( ) ; } } Ok ( ( ) ) }
Adds the necessary labels to this Error, and unpins the session if needed.
Adds the necessary labels to this Error and unpins the session if needed .
&mut self
conn
Option<&Connection>
session
&mut Option<&mut ClientSession>
retryability
Option<&Retryability>
&mut self
conn
Option<&Connection>
session
&mut Option<&mut ClientSession>
retryability
Option<&Retryability>