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: fps_monitor.rs
    path of file: ./repos/mk48/engine/client_util/src
    
    the code of the file until where you have to start completion: // SPDX-FileCopyrightText: 2021 Softbear, Inc.
// SPDX-License-Identifier: AGPL-3.0-or-later

/// Counts frames per second over a period.
pub struct FpsMonitor {
    elapsed: f32,
    period: f32,
    frames: u32,
    last_sample: Option<f32>,
}

impl FpsMonitor {
    pub fn new(period: f32) -> Self {
        Self {
            period,
            elapsed: 0.0,
            frames: 0,
            last_sample: None,
        }
    }

    /// Returns the fps for the previous period.
    pub fn last_sample(&self) -> Option<f32> {
    
    pub fn update(&mut self, delta_seconds: f32) -> Option<f32> {
        self.frames = self.frames.saturating_add(1);
        self.elapsed += delta_seconds;

        if self.elapsed
            >= if self.last_sample.is_none() {
                (self.period * 0.1).max(1.0)
            } else {
                self.period
            }
        {
            let fps = self.frames as f32 / self.elapsed;
            self.elapsed = 0.0;
            self.frames = 0;
            self.last_sample = Some(fps);
            Some(fps)
        } else {
            None
        }
    }