You are an expert in writing code in many different languages. Your goal is to perform code completion for the following code, keeping in mind the rest of the code and the file meta data.
    Metadata details:
    filename: eta_calculator.rs
    path of file: ./repos/qdrant/lib/collection/src/common
    
    the code of the file until where you have to start completion: use std::time::{Duration, Instant};

use ringbuffer::{ConstGenericRingBuffer, RingBuffer as _};

/// A progress ETA calculator.
/// Calculates the ETA roughly based on the last ten seconds of measurements.
pub struct EtaCalculator(ConstGenericRingBuffer<(Instant, us
    
    fn test_eta_calculator() {
        let mut now = Instant::now();
        let mut eta = EtaCalculator::new();

        let delta = Duration::from_millis(500);
        for i in 0..=40 {
            now += delta;
            eta.set_progress_raw(now, i);
        }
        assert_relative_eq!(
            eta.estimate_raw(now, 100).unwrap().as_secs_f64(),
            ((100 - 40) * delta).as_secs_f64(),
            max_relative = 0.02,
        );
        // Emulate a stall.
        assert!(eta
            .estimate_raw(now + Duration::from_secs(20), 100)
            .is_none());

        // Change the speed.
        let delta = Duration::from_millis(5000);
        for i in 41..=60 {
            now += delta;
            eta.set_progress_raw(now, i);
        }
        assert_relative_eq!(
            eta.estimate_raw(now, 100).unwrap().as_secs_f64(),
            ((100 - 60) * delta).as_secs_f64(),
            max_relative = 0.02,
        );

        // Should be 0 when the target progress is reached or overreached.
        assert_eq!(eta.estimate_raw(now, 60).unwrap(), Duration::from_secs(0));
        assert_eq!(eta.estimate_raw(now, 50).unwrap(), Duration::from_secs(0));
    }