namespace AIStudio.Tools.Services.Indexing; /// /// The file system changes of one data source which WatcherChangeTally counted instead of logging each. /// /// How many changes concerned no file of the RAG index. /// How many changes concerned the RAG index. /// The path of the last change, or an empty string without any. internal readonly record struct WatcherChangeCounts(int Ignored, int Relevant, string LastPath) { /// /// No change counted. /// public static readonly WatcherChangeCounts NONE = new(0, 0, string.Empty); /// /// How many changes were counted. /// public int Total => this.Ignored + this.Relevant; /// /// Counts one more change. /// /// The path of the change. /// Whether the change concerns the RAG index. /// The counts including this change. public WatcherChangeCounts Add(string path, bool isRelevant) => isRelevant ? this with { Relevant = this.Relevant + 1, LastPath = path } : this with { Ignored = this.Ignored + 1, LastPath = path }; }