pub fn ack_range(&mut self, start: StreamPos, end: StreamPos) -> AckResult {
        match self
            .unacked_ranges
            .binary_search_by(|(range_start, _)| stream_cmp(range_start, &start))
        {
            Ok(i) => {
                if stream_gt(&end, &self.unacked_ranges[i].1) {
                    AckResult::InvalidRange
                } else {
                    let unacked_start = self.unacked_start();
                    if end == self.unacked_ranges[i].1 {
                        self.unacked_ranges.remove(i);

                        if start == unacked_start {
                            assert_eq!(i, 0);
                            if self.unacked_ranges.is_empty() {
                                self.buffer.drain(0..self.sent as usize);
                                self.sent = 0;
                            } else {
                                let acked_amt = (self.unacked_ranges[0].0 - start).0;
                                self.buffer.drain(0..acked_amt as usize);
                                self.sent -= acked_amt;
                            }
                        }
                        AckResult::Ack
                    } else {
                        if start == unacked_start {
                            assert_eq!(i, 0);
                            let acked_amt = (end - start).0;
                            self.buffer.drain(0..acked_amt as usize);
                            self.sent -= acked_amt;
                        }

                        self.unacked_ranges[i].0 = end;
                        AckResult::PartialAck(self.unacked_ranges[i].1)
                    }
                }
            }
            Err(_) => AckResult::NotFound,
        }
    }
/// Acknowledge the receipt of the given stream range from the remote, and thus potentially free
/// up send buffer space.
///
/// Acknowledged ranges are allowed to be equal to or shorter than the sent ranges, but they
/// *must* start with the same stream position.  Acked ranges will be ignored if they are empty
/// or do not start with the same position as a previously sent, unacked range.
Acknowledge the receipt of the given stream range from the remote, and thus potentially free
up send buffer space.

Acknowledged ranges are allowed to be equal to or shorter than the sent ranges, but they
must* start with the same stream position.  Acked ranges will be ignored if they are empty
or do not start with the same position as a previously sent, unacked range.
Acknowledge the receipt of the given stream range from the remote and thus potentially free up send buffer space . Acknowledged ranges are allowed to be equal to or shorter than the sent ranges but they must * start with the same stream position . Acked ranges will be ignored if they are empty or do not start with the same position as a previously sent unacked range .
pub fn ack_range(&mut self, start: StreamPos, end: StreamPos) -> AckResult {
        match self
            .unacked_ranges
            .binary_search_by(|(range_start, _)| stream_cmp(range_start, &start))
        {
            Ok(i) => {
                if stream_gt(&end, &self.unacked_ranges[i].1) {
                    AckResult::InvalidRange
                } else {
                    let unacked_start = self.unacked_start();
                    if end == self.unacked_ranges[i].1 {
                        self.unacked_ranges.remove(i);
                        if start == unacked_start {
                            assert_eq!(i, 0);
                            if self.unacked_ranges.is_empty() {
                                self.buffer.drain(0..self.sent as usize);
                                self.sent = 0;
                            } else {
                                let acked_amt = (self.unacked_ranges[0].0 - start).0;
                                self.buffer.drain(0..acked_amt as usize);
                                self.sent -= acked_amt;
                            }
                        }
                        AckResult::Ack
                    } else {
                        if start == unacked_start {
                            assert_eq!(i, 0);
                            let acked_amt = (end - start).0;
                            self.buffer.drain(0..acked_amt as usize);
                            self.sent -= acked_amt;
                        }
                        self.unacked_ranges[i].0 = end;
                        AckResult::PartialAck(self.unacked_ranges[i].1)
                    }
                }
            }
            Err(_) => AckResult::NotFound,
        }
    }
pub fn ack_range ( & mut self , start : StreamPos , end : StreamPos ) -> AckResult { match self . unacked_ranges . binary_search_by ( | ( range_start , _ ) | stream_cmp ( range_start , & start ) ) { Ok ( i ) => { if stream_gt ( & end , & self . unacked_ranges [ i ] . 1 ) { AckResult :: InvalidRange } else { let unacked_start = self . unacked_start ( ) ; if end == self . unacked_ranges [ i ] . 1 { self . unacked_ranges . remove ( i ) ; if start == unacked_start { assert_eq ! ( i 0 ) ; if self . unacked_ranges . is_empty ( ) { self . buffer . drain ( 0 .. self . sent as usize ) ; self . sent = 0 ; } else { let acked_amt = ( self . unacked_ranges [ 0 ] . 0 - start ) . 0 ; self . buffer . drain ( 0 .. acked_amt as usize ) ; self . sent -= acked_amt ; } } AckResult :: Ack } else { if start == unacked_start { assert_eq ! ( i 0 ) ; let acked_amt = ( end - start ) . 0 ; self . buffer . drain ( 0 .. acked_amt as usize ) ; self . sent -= acked_amt ; } self . unacked_ranges [ i ] . 0 = end ; AckResult :: PartialAck ( self . unacked_ranges [ i ] . 1 ) } } } Err ( _ ) => AckResult :: NotFound , } }
Acknowledge the receipt of the given stream range from the remote, and thus potentially free
up send buffer space.
Acknowledge the receipt of the given stream range from the remote and thus potentially free up send buffer space .
&mut self
start
StreamPos
end
StreamPos
&mut self
start
StreamPos
end
StreamPos