// What `/photos?show=` names: the whole library or its pictures (the films // are the Videos tool's own list, `/videos`) — // the route's value, read leniently, and the library list's filter word it // opens on (`media`'s `kind`). Storage opens the library by it too. import Foundation public enum PhotosShow: String, CaseIterable, Sendable { case all case photos /// The route's `show` value, read leniently: anything this build does not /// know shows the whole library rather than an empty one. public init(route value: String?) { self = value.flatMap(PhotosShow.init(rawValue:)) ?? .all } /// What goes back into the route — `nil` for the whole library, so the /// plain `/photos` link stays the plain link. public var routeValue: String? { self == .all ? nil : rawValue } /// What the library is headed when it is opened to show this: nil keeps /// the table's own name ("Photos"). public var title: String? { nil } /// The library's filter value it opens on: the `kind` it narrows to, or /// nil for all. public var kind: String? { switch self { case .all: return nil case .photos: return "photo" } } }