fn maybe_update(&mut self, latest: Self) -> Option<EventData> {
        let mut emit_event = false;

        let new_min_rtt = if self.min_rtt != latest.min_rtt {
            self.min_rtt = latest.min_rtt;
            emit_event = true;
            Some(latest.min_rtt.as_secs_f32() * 1000.0)
        } else {
            None
        };

        let new_smoothed_rtt = if self.smoothed_rtt != latest.smoothed_rtt {
            self.smoothed_rtt = latest.smoothed_rtt;
            emit_event = true;
            Some(latest.smoothed_rtt.as_secs_f32() * 1000.0)
        } else {
            None
        };

        let new_latest_rtt = if self.latest_rtt != latest.latest_rtt {
            self.latest_rtt = latest.latest_rtt;
            emit_event = true;
            Some(latest.latest_rtt.as_secs_f32() * 1000.0)
        } else {
            None
        };

        let new_rttvar = if self.rttvar != latest.rttvar {
            self.rttvar = latest.rttvar;
            emit_event = true;
            Some(latest.rttvar.as_secs_f32() * 1000.0)
        } else {
            None
        };

        let new_cwnd = if self.cwnd != latest.cwnd {
            self.cwnd = latest.cwnd;
            emit_event = true;
            Some(latest.cwnd)
        } else {
            None
        };

        let new_bytes_in_flight =
            if self.bytes_in_flight != latest.bytes_in_flight {
                self.bytes_in_flight = latest.bytes_in_flight;
                emit_event = true;
                Some(latest.bytes_in_flight)
            } else {
                None
            };

        let new_ssthresh = if self.ssthresh != latest.ssthresh {
            self.ssthresh = latest.ssthresh;
            emit_event = true;
            Some(latest.ssthresh)
        } else {
            None
        };

        if emit_event {
            // QVis can't use all these fields and they can be large.
            return Some(EventData::MetricsUpdated(
                qlog::events::quic::MetricsUpdated {
                    min_rtt: new_min_rtt,
                    smoothed_rtt: new_smoothed_rtt,
                    latest_rtt: new_latest_rtt,
                    rtt_variance: new_rttvar,
                    pto_count: None,
                    congestion_window: new_cwnd,
                    bytes_in_flight: new_bytes_in_flight,
                    ssthresh: new_ssthresh,
                    packets_in_flight: None,
                    pacing_rate: None,
                },
            ));
        }

        None
    }
// Make a qlog event if the latest instance of QlogMetrics is different.
//
// This function diffs each of the fields. A qlog MetricsUpdated event is
// only generated if at least one field is different. Where fields are
// different, the qlog event contains the latest value.
Make a qlog event if the latest instance of QlogMetrics is different.
This function diffs each of the fields. A qlog MetricsUpdated event is
only generated if at least one field is different. Where fields are
different, the qlog event contains the latest value.
Make a qlog event if the latest instance of QlogMetrics is different . This function diffs each of the fields . A qlog MetricsUpdated event is only generated if at least one field is different . Where fields are different the qlog event contains the latest value .
fn maybe_update(&mut self, latest: Self) -> Option<EventData> {
        let mut emit_event = false;
        let new_min_rtt = if self.min_rtt != latest.min_rtt {
            self.min_rtt = latest.min_rtt;
            emit_event = true;
            Some(latest.min_rtt.as_secs_f32() * 1000.0)
        } else {
            None
        };
        let new_smoothed_rtt = if self.smoothed_rtt != latest.smoothed_rtt {
            self.smoothed_rtt = latest.smoothed_rtt;
            emit_event = true;
            Some(latest.smoothed_rtt.as_secs_f32() * 1000.0)
        } else {
            None
        };
        let new_latest_rtt = if self.latest_rtt != latest.latest_rtt {
            self.latest_rtt = latest.latest_rtt;
            emit_event = true;
            Some(latest.latest_rtt.as_secs_f32() * 1000.0)
        } else {
            None
        };
        let new_rttvar = if self.rttvar != latest.rttvar {
            self.rttvar = latest.rttvar;
            emit_event = true;
            Some(latest.rttvar.as_secs_f32() * 1000.0)
        } else {
            None
        };
        let new_cwnd = if self.cwnd != latest.cwnd {
            self.cwnd = latest.cwnd;
            emit_event = true;
            Some(latest.cwnd)
        } else {
            None
        };
        let new_bytes_in_flight =
            if self.bytes_in_flight != latest.bytes_in_flight {
                self.bytes_in_flight = latest.bytes_in_flight;
                emit_event = true;
                Some(latest.bytes_in_flight)
            } else {
                None
            };
        let new_ssthresh = if self.ssthresh != latest.ssthresh {
            self.ssthresh = latest.ssthresh;
            emit_event = true;
            Some(latest.ssthresh)
        } else {
            None
        };
        if emit_event {
            // QVis can't use all these fields and they can be large.
            return Some(EventData::MetricsUpdated(
                qlog::events::quic::MetricsUpdated {
                    min_rtt: new_min_rtt,
                    smoothed_rtt: new_smoothed_rtt,
                    latest_rtt: new_latest_rtt,
                    rtt_variance: new_rttvar,
                    pto_count: None,
                    congestion_window: new_cwnd,
                    bytes_in_flight: new_bytes_in_flight,
                    ssthresh: new_ssthresh,
                    packets_in_flight: None,
                    pacing_rate: None,
                },
            ));
        }
        None
    }
fn maybe_update ( & mut self , latest : Self ) -> Option < EventData > { let mut emit_event = false ; let new_min_rtt = if self . min_rtt != latest . min_rtt { self . min_rtt = latest . min_rtt ; emit_event = true ; Some ( latest . min_rtt . as_secs_f32 ( ) * 1000.0 ) } else { None } ; let new_smoothed_rtt = if self . smoothed_rtt != latest . smoothed_rtt { self . smoothed_rtt = latest . smoothed_rtt ; emit_event = true ; Some ( latest . smoothed_rtt . as_secs_f32 ( ) * 1000.0 ) } else { None } ; let new_latest_rtt = if self . latest_rtt != latest . latest_rtt { self . latest_rtt = latest . latest_rtt ; emit_event = true ; Some ( latest . latest_rtt . as_secs_f32 ( ) * 1000.0 ) } else { None } ; let new_rttvar = if self . rttvar != latest . rttvar { self . rttvar = latest . rttvar ; emit_event = true ; Some ( latest . rttvar . as_secs_f32 ( ) * 1000.0 ) } else { None } ; let new_cwnd = if self . cwnd != latest . cwnd { self . cwnd = latest . cwnd ; emit_event = true ; Some ( latest . cwnd ) } else { None } ; let new_bytes_in_flight = if self . bytes_in_flight != latest . bytes_in_flight { self . bytes_in_flight = latest . bytes_in_flight ; emit_event = true ; Some ( latest . bytes_in_flight ) } else { None } ; let new_ssthresh = if self . ssthresh != latest . ssthresh { self . ssthresh = latest . ssthresh ; emit_event = true ; Some ( latest . ssthresh ) } else { None } ; if emit_event { // QVis can't use all these fields and they can be large. return Some ( EventData :: MetricsUpdated ( qlog :: events :: quic :: MetricsUpdated { min_rtt : new_min_rtt , smoothed_rtt : new_smoothed_rtt , latest_rtt : new_latest_rtt , rtt_variance : new_rttvar , pto_count : None , congestion_window : new_cwnd , bytes_in_flight : new_bytes_in_flight , ssthresh : new_ssthresh , packets_in_flight : None , pacing_rate : None , } , ) ) ; } None }
Make a qlog event if the latest instance of QlogMetrics is different.
Make a qlog event if the latest instance of QlogMetrics is different .
&mut self
latest
Self
&mut self
latest
Self