Read any feed type using the universal Feed enum
mainWhen the feed format is unknown, use the universal Feed enum. It automatically detects whether the feed is RSS, Atom, or JSON before parsing and decoding. You can then use a switch statement to handle the specific resulting model.
// Read any type of feed
let feed = try await Feed(urlString: "https://surprise.me/feed")
// Use a switch to get the resulting feed model
switch feed {
case let .atom(feed): // An AtomFeed instance
case let .rss(feed): // An RSSFeed instance
case let .json(feed): // A JSONFeed instance
}