using System; namespace MediaBrowser.Controller.Library; /// /// Represents an item matched by a search query with its relevance score. /// public readonly struct SearchResult : IEquatable { /// /// Initializes a new instance of the struct. /// /// The item ID. /// The relevance score. public SearchResult(Guid itemId, float score) { ItemId = itemId; Score = score; } /// /// Gets the ID of the matching item. /// public Guid ItemId { get; init; } /// /// Gets the relevance score. Higher values indicate more relevant results. /// public float Score { get; init; } /// /// Compares two instances for equality. /// /// The left operand. /// The right operand. /// True if the instances are equal; otherwise, false. public static bool operator ==(SearchResult left, SearchResult right) => left.Equals(right); /// /// Compares two instances for inequality. /// /// The left operand. /// The right operand. /// True if the instances are not equal; otherwise, false. public static bool operator !=(SearchResult left, SearchResult right) => !left.Equals(right); /// public override bool Equals(object? obj) => obj is SearchResult other && Equals(other); /// public bool Equals(SearchResult other) => ItemId.Equals(other.ItemId) && Score.Equals(other.Score); /// public override int GetHashCode() => HashCode.Combine(ItemId, Score); }