misc: rate_limiter: streamline #[source] and Error impl

This streamlines the Error implementation in the Cloud Hypervisor code
base to match the remaining parts so that everything follows the agreed
conventions. These are leftovers missed in the previous commits.

Signed-off-by: Philipp Schuster <philipp.schuster@cyberus-technology.de>
On-behalf-of: SAP philipp.schuster@sap.com
This commit is contained in:
Philipp Schuster 2025-05-21 13:32:39 +02:00 committed by Rob Bradford
parent 0cde3df44a
commit f934e142ba

View file

@ -52,18 +52,21 @@ use std::sync::atomic::{AtomicBool, Ordering};
use std::sync::Mutex;
use std::time::{Duration, Instant};
use thiserror::Error;
use vmm_sys_util::timerfd::TimerFd;
/// Module for group rate limiting.
pub mod group;
#[derive(Debug)]
#[derive(Error, Debug)]
/// Describes the errors that may occur while handling rate limiter events.
pub enum Error {
/// The event handler was called spuriously.
#[error("Event handler was called spuriously: {0}")]
SpuriousRateLimiterEvent(&'static str),
/// The event handler encounters while TimerFd::wait()
TimerFdWaitError(std::io::Error),
#[error("Failed to wait for the timer: {0}")]
TimerFdWaitError(#[source] std::io::Error),
}
// Interval at which the refill timer will run when limiter is at capacity.