use core::cmp::Ordering;
use super::{
frame::settings::{DEFAULT_INITIAL_WINDOW_SIZE, Settings},
window::RecvWindow,
};
#[derive(Clone, Copy)]
pub(super) struct RecvWindowThreshold(RecvWindow);
impl From<&Settings> for RecvWindowThreshold {
fn from(settings: &Settings) -> Self {
let window = settings.initial_window_size().unwrap_or(DEFAULT_INITIAL_WINDOW_SIZE);
let threshold = window * 3 / 4;
Self(RecvWindow::new(threshold))
}
}
impl PartialEq<RecvWindowThreshold> for RecvWindow {
fn eq(&self, other: &RecvWindowThreshold) -> bool {
self.eq(&other.0)
}
}
impl PartialOrd<RecvWindowThreshold> for RecvWindow {
fn partial_cmp(&self, other: &RecvWindowThreshold) -> Option<Ordering> {
self.partial_cmp(&other.0)
}
}