pub(crate) fn update(
        &mut self,
        mut server_description: ServerDescription,
    ) -> Result<(), String> {
        // Ignore updates from servers not currently in the cluster.
        if !self.servers.contains_key(&server_description.address) {
            return Ok(());
        }

        // Update the round trip time on the server description to the weighted average as described
        // by the spec.
        self.update_round_trip_time(&mut server_description);

        // Replace the old info about the server with the new info.
        self.servers.insert(
            server_description.address.clone(),
            server_description.clone(),
        );

        if let TopologyType::LoadBalanced = self.topology_type {
            // Load-balanced topologies don't have real server updates; attempting to update based
            // on the synthesized one causes incorrect behavior.
            return Ok(());
        }

        // Update the topology's min logicalSessionTimeout.
        self.update_session_support_status(&server_description);

        // Update the topology's transaction support status.
        self.update_transaction_support_status(&server_description);

        // Update the topology's max reported $clusterTime.
        if let Some(ref cluster_time) = server_description.cluster_time().ok().flatten() {
            self.advance_cluster_time(cluster_time);
        }

        // Update the topology description based on the current topology type.
        match self.topology_type {
            TopologyType::Single | TopologyType::LoadBalanced => {}
            TopologyType::Unknown => self.update_unknown_topology(server_description)?,
            TopologyType::Sharded => self.update_sharded_topology(server_description),
            TopologyType::ReplicaSetNoPrimary => {
                self.update_replica_set_no_primary_topology(server_description)?
            }
            TopologyType::ReplicaSetWithPrimary => {
                self.update_replica_set_with_primary_topology(server_description)?;
            }
        }

        // Record any compatibility error.
        self.check_compatibility();

        Ok(())
    }
/// Update the topology based on the new information about the topology contained by the
/// ServerDescription.
Update the topology based on the new information about the topology contained by the
ServerDescription.
Update the topology based on the new information about the topology contained by the ServerDescription .
pub(crate) fn update(
        &mut self,
        mut server_description: ServerDescription,
    ) -> Result<(), String> {
        // Ignore updates from servers not currently in the cluster.
        if !self.servers.contains_key(&server_description.address) {
            return Ok(());
        }
        // Update the round trip time on the server description to the weighted average as described
        // by the spec.
        self.update_round_trip_time(&mut server_description);
        // Replace the old info about the server with the new info.
        self.servers.insert(
            server_description.address.clone(),
            server_description.clone(),
        );
        if let TopologyType::LoadBalanced = self.topology_type {
            // Load-balanced topologies don't have real server updates; attempting to update based
            // on the synthesized one causes incorrect behavior.
            return Ok(());
        }
        // Update the topology's min logicalSessionTimeout.
        self.update_session_support_status(&server_description);
        // Update the topology's transaction support status.
        self.update_transaction_support_status(&server_description);
        // Update the topology's max reported $clusterTime.
        if let Some(ref cluster_time) = server_description.cluster_time().ok().flatten() {
            self.advance_cluster_time(cluster_time);
        }
        // Update the topology description based on the current topology type.
        match self.topology_type {
            TopologyType::Single | TopologyType::LoadBalanced => {}
            TopologyType::Unknown => self.update_unknown_topology(server_description)?,
            TopologyType::Sharded => self.update_sharded_topology(server_description),
            TopologyType::ReplicaSetNoPrimary => {
                self.update_replica_set_no_primary_topology(server_description)?
            }
            TopologyType::ReplicaSetWithPrimary => {
                self.update_replica_set_with_primary_topology(server_description)?;
            }
        }
        // Record any compatibility error.
        self.check_compatibility();
        Ok(())
    }
pub ( crate ) fn update ( & mut self , mut server_description : ServerDescription , ) -> Result < ( ) , String > { // Ignore updates from servers not currently in the cluster. if ! self . servers . contains_key ( & server_description . address ) { return Ok ( ( ) ) ; } // Update the round trip time on the server description to the weighted average as described // by the spec. self . update_round_trip_time ( & mut server_description ) ; // Replace the old info about the server with the new info. self . servers . insert ( server_description . address . clone ( ) , server_description . clone ( ) , ) ; if let TopologyType :: LoadBalanced = self . topology_type { // Load-balanced topologies don't have real server updates; attempting to update based // on the synthesized one causes incorrect behavior. return Ok ( ( ) ) ; } // Update the topology's min logicalSessionTimeout. self . update_session_support_status ( & server_description ) ; // Update the topology's transaction support status. self . update_transaction_support_status ( & server_description ) ; // Update the topology's max reported $clusterTime. if let Some ( ref cluster_time ) = server_description . cluster_time ( ) . ok ( ) . flatten ( ) { self . advance_cluster_time ( cluster_time ) ; } // Update the topology description based on the current topology type. match self . topology_type { TopologyType :: Single | TopologyType :: LoadBalanced => { } TopologyType :: Unknown => self . update_unknown_topology ( server_description ) ? , TopologyType :: Sharded => self . update_sharded_topology ( server_description ) , TopologyType :: ReplicaSetNoPrimary => { self . update_replica_set_no_primary_topology ( server_description ) ? } TopologyType :: ReplicaSetWithPrimary => { self . update_replica_set_with_primary_topology ( server_description ) ? ; } } // Record any compatibility error. self . check_compatibility ( ) ; Ok ( ( ) ) }
Update the topology based on the new information about the topology contained by the
ServerDescription.
Update the topology based on the new information about the topology contained by the ServerDescription .
&mut self
server_description
ServerDescription
&mut self
server_description
ServerDescription