Cotton code
26 lines · 866 B · SwiftRaw
// The project slugs used to narrow records. An empty set means every project.import Foundationpublic struct ProjectScope: Equatable, Hashable, Sendable {    /// The slugs in scope. Empty is every project.    public let slugs: Set<String>    public init(_ slugs: Set<String> = []) {        self.slugs = slugs    }    /// Every project — the default, and the phone's only value.    public static let all = ProjectScope()    /// No narrowing at all.    public var isAll: Bool { slugs.isEmpty }    /// Whether `slug` is one of the chosen projects. Under `.all` nothing is    /// "chosen", so this is false — the All row is what is lit.    public func contains(_ slug: String) -> Bool { slugs.contains(slug) }    /// The slugs in a stable order, for a read's arguments and a row of chips.    public var ordered: [String] { slugs.sorted() }}