|
23 | 23 | //
|
24 | 24 |
|
25 | 25 | import Foundation
|
26 |
| -/// Types of feed. |
| 26 | + |
| 27 | +/// Types of feed: RSS, RDF, Atom, and JSON. |
| 28 | +/// |
| 29 | +/// The `FeedType` enum helps detect the feed format based on raw data. |
| 30 | +/// It provides methods to determine if the feed is XML-based or JSON-based. |
| 31 | +/// |
| 32 | +/// **Note:** FeedKit handles the automatic determination of the feed type during |
| 33 | +/// parsing, so you generally don't need to manually detect the feed type. However, |
| 34 | +/// using `FeedType` can be helpful when you want to identify the feed type without |
| 35 | +/// parsing or decoding the entire feed. |
| 36 | +/// |
| 37 | +/// Example using `switch`: |
| 38 | +/// ```swift |
| 39 | +/// if let feed = FeedType(data: feedData) { |
| 40 | +/// switch feed { |
| 41 | +/// case .rss: |
| 42 | +/// print("RSS feed detected") |
| 43 | +/// case .rdf: |
| 44 | +/// print("RDF feed detected") |
| 45 | +/// case .atom: |
| 46 | +/// print("Atom feed detected") |
| 47 | +/// case .json: |
| 48 | +/// print("JSON feed detected") |
| 49 | +/// } |
| 50 | +/// } |
27 | 51 | ///
|
28 |
| -/// - atom: The `Atom Syndication Format` feed type. |
29 |
| -/// - rdf: The `Really Simple Syndication` feed type version 0.90. |
30 |
| -/// - rss: The `Really Simple Syndication` feed type version 2.0. |
31 |
| -/// - json: JSON formatted feed, commonly used for web APIs. |
| 52 | +/// Example using `if`: |
| 53 | +/// ```swift |
| 54 | +/// if let feed = FeedType(data: feedData) { |
| 55 | +/// if feed.isXML { |
| 56 | +/// print("XML-based feed detected") |
| 57 | +/// } else if feed.isJson { |
| 58 | +/// print("JSON feed detected") |
| 59 | +/// } |
| 60 | +/// } |
| 61 | +/// ``` |
32 | 62 | public enum FeedType {
|
| 63 | + /// Represents the RSS 2.0 feed format. |
33 | 64 | case rss
|
| 65 | + /// Represents the RDF 0.90 feed format. |
34 | 66 | case rdf
|
| 67 | + /// Represents the Atom Syndication Format feed. |
35 | 68 | case atom
|
| 69 | + /// Represents a JSON-formatted feed, commonly used in web APIs. |
36 | 70 | case json
|
37 | 71 | }
|
38 | 72 |
|
|
0 commit comments