namespace AIStudio.Tools.Pauses; /// /// The shortest and the longest pause a feature allows for either bound of its random pause, cf. PauseRange. /// /// /// Each feature sets its own limits next to its settings: the indexing allows no pause at all, for /// example, while the batch processing always pauses for a few seconds. /// /// The shortest pause either bound may ask for. /// The longest pause either bound may ask for. public sealed record PauseLimits(int ShortestSeconds, int LongestSeconds) { /// /// Whether a bound lies within the limits, e.g., one which a configuration plugin sets. /// /// The bound. /// True when the feature allows the bound. public bool Allows(int seconds) => seconds >= this.ShortestSeconds && seconds <= this.LongestSeconds; /// /// Moves a bound into the limits. /// /// The bound. /// The bound, or the limit it went beyond. public int Clamp(int seconds) => Math.Clamp(seconds, this.ShortestSeconds, this.LongestSeconds); }