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: update_loop.rs
    path of file: ./repos/neovide/src/window
    
    the code of the file until where you have to start completion: use std::time::{Duration, Instant};

use winit::{
    event::{Event, WindowEvent},
    event_loop::ControlFlow,
};

use super::{UserEvent, WindowSettings, WinitWindowWrapper};
use crate::{
    profiling::{tracy_create_gpu_context, tracy_plot, tracy_zone},
    settings::SETTINGS,
};

enum FocusedState {
    Focused,
    UnfocusedNotDrawn,
    Unfocused,
}

#[derive(Debug, PartialEq)]
pub enum ShouldRender {
    Immediately,
    Wait,
    Deadline(Instant),
}

impl ShouldRender {
    pub fn update(&mut self, rhs: ShouldRender) {
        let lhs = &self;
        match (lhs, rhs) {
            (ShouldRender::Immediately, _) => {}
            (_, ShouldRender::Immediately) => {
                *self = ShouldRender::Immediately;
            }
            (ShouldRender::Deadline(lhs), ShouldRender::Deadline(rhs)) => {
                if rhs < *lhs {
                    *self = ShouldRender::Deadline(rhs);
                }
            }
            (ShouldRender::Deadline(_), ShouldRender::Wait) => {}
            (ShouldRender::Wait, ShouldRender::Deadline(instant)) => {
                *self = ShouldRender::Deadline(instant);
           
    
    pub fn get_event_wait_time(&self) -> (Duration, Instant) {
        let refresh_rate = match self.focused {
            // NOTE: Always wait for the idle refresh rate when winit throttling is used to avoid waking up too early
            // The winit redraw request will likely happen much before that and wake it up anyway
            FocusedState::Focused | FocusedState::UnfocusedNotDrawn => {
                SETTINGS.get::<WindowSettings>().refresh_rate as f32
            }
            _ => SETTINGS.get::<WindowSettings>().refresh_rate_idle as f32,
        }
        .max(1.0);

        let expected_frame_duration = Duration::from_secs_f32(1.0 / refresh_rate);
        if self.should_render == ShouldRender::Immediately && !self.pending_render {
            (Duration::from_nanos(0), Instant::now())
        } else if self.pending_render {
            let deadline = self.animation_start + self.simulation_time;
            (deadline.saturating_duration_since(Instant::now()), deadline)
        } else {
            let mut deadline = self.previous_frame_start + expected_frame_duration;
            deadline = match self.should_render {
                ShouldRender::Deadline(should_render_deadline) => {
                    should_render_deadline.min(deadline)
                }
                _ => deadline,
            };
            (deadline.saturating_duration_since(Instant::now()), deadline)
        }
    }