using System; namespace CryptoExchange.Net.RateLimiting { /// /// Limit check /// public readonly struct LimitCheck { /// /// Is guard applicable /// public bool Applicable { get; } /// /// Delay needed /// public TimeSpan Delay { get; } /// /// Current counter /// public int Current { get; } /// /// Limit /// public int? Limit { get; } /// /// Time period /// public TimeSpan? Period { get; } private LimitCheck(bool applicable, TimeSpan delay, int limit, TimeSpan period, int current) { Applicable = applicable; Delay = delay; Limit = limit; Period = period; Current = current; } /// /// Not applicable /// public static LimitCheck NotApplicable { get; } = new LimitCheck(false, default, default, default, default); /// /// No wait needed /// public static LimitCheck NotNeeded(int limit, TimeSpan period, int current) => new(true, default, limit, period, current); /// /// Wait needed /// /// The delay needed /// Limit per period /// Period the limit is for /// Current counter /// public static LimitCheck Needed(TimeSpan delay, int limit, TimeSpan period, int current) => new(true, delay, limit, period, current); } }