-
Notifications
You must be signed in to change notification settings - Fork 117
/
ParseData.swift
51 lines (43 loc) · 1.34 KB
/
ParseData.swift
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
//
// Copyright 2024 Readium Foundation. All rights reserved.
// Use of this source code is governed by the BSD-style license
// available in the top-level LICENSE file of the project.
//
import Foundation
import ReadiumShared
/// List of OPDS versions compliant with the parser.
public enum Version {
/// OPDS 1.x must be an XML ressource
case OPDS1
/// OPDS 2.x must be a JSON ressource
case OPDS2
}
/// An intermediate structure return when the generic helper method public static
/// func parseURL(url: URL, completion: (ParseData?, Error?) -> Void) from OPDSParser class is called.
public struct ParseData {
/// The ressource URL
public var url: URL
/// The URLResponse got after fetching the ressource
public var response: URLResponse
/// The OPDS version
public var version: Version
/// The feed
public var feed: Feed? {
didSet {
// Publication is nil when feed is not
if feed != nil { publication = nil }
}
}
/// The publication
public var publication: Publication? {
didSet {
// Feed is nil when publication is not
if publication != nil { feed = nil }
}
}
init(url: URL, response: URLResponse, version: Version) {
self.url = url
self.response = response
self.version = version
}
}