pub fn discard_before(&mut self, new_begin: StreamIndex) {
        // Update stats for each discarded message.
        for (index, msg) in self.stream.messages().iter() {
            if index >= new_begin {
                break;
            }
            if let RequestOrResponse::Response(response) = &msg {
                let canister_responses_size_bytes = self
                    .responses_size_bytes
                    .get_mut(&response.respondent)
                    .expect("No `responses_size_bytes` entry for discarded response");
                *canister_responses_size_bytes -= msg.count_bytes();
                // Drop zero counts.
                if *canister_responses_size_bytes == 0 {
                    self.responses_size_bytes.remove(&response.respondent);
                }
            }
        }

        self.stream.discard_before(new_begin);
    }
/// Garbage collects messages before `new_begin`.
Garbage collects messages before `new_begin`.
Garbage collects messages before ` new_begin ` .
pub fn discard_before(&mut self, new_begin: StreamIndex) {
        // Update stats for each discarded message.
        for (index, msg) in self.stream.messages().iter() {
            if index >= new_begin {
                break;
            }
            if let RequestOrResponse::Response(response) = &msg {
                let canister_responses_size_bytes = self
                    .responses_size_bytes
                    .get_mut(&response.respondent)
                    .expect("No `responses_size_bytes` entry for discarded response");
                *canister_responses_size_bytes -= msg.count_bytes();
                // Drop zero counts.
                if *canister_responses_size_bytes == 0 {
                    self.responses_size_bytes.remove(&response.respondent);
                }
            }
        }
        self.stream.discard_before(new_begin);
    }
pub fn discard_before ( & mut self , new_begin : StreamIndex ) { // Update stats for each discarded message. for ( index , msg ) in self . stream . messages ( ) . iter ( ) { if index >= new_begin { break ; } if let RequestOrResponse :: Response ( response ) = & msg { let canister_responses_size_bytes = self . responses_size_bytes . get_mut ( & response . respondent ) . expect ( " " ) ; * canister_responses_size_bytes -= msg . count_bytes ( ) ; // Drop zero counts. if * canister_responses_size_bytes == 0 { self . responses_size_bytes . remove ( & response . respondent ) ; } } } self . stream . discard_before ( new_begin ) ; }
Garbage collects messages before `new_begin`.
Garbage collects messages before ` new_begin ` .
&mut self
new_begin
StreamIndex
&mut self
new_begin
StreamIndex