RSDResourceTransformer
public protocol RSDResourceTransformer : RSDDecodableBundleInfo
RSDResourceTransformer
is a protocol for getting either embedded resources or online resources.
-
Either a fully qualified URL string or else a relative reference to either an embedded resource or a relative URL defined globally by overriding the
RSDResourceConfig
class methods.Declaration
Swift
var resourceName: String { get }
-
The classType for converting the resource to an object.
Declaration
Swift
var classType: String? { get }
-
estimatedFetchTime
Extension methodThe estimated time required to fetch the resource.
Declaration
Swift
public var estimatedFetchTime: TimeInterval { get }
-
isOnlineResourceURL()
Extension methodWhether or not the resource is an online URL or from an embedded resource bundle.
Declaration
Swift
public func isOnlineResourceURL() -> Bool
Return Value
true
if the resource is an online URL orfalse
if it is an embedded resource. -
fullURL()
Extension methodGet the full URL for a given resource no matter if it is a local or online resource.
Throws
RSDResourceTransformerError
if the file cannot be found, orRSDValidationError
if the online resource is not valid.Declaration
Swift
public func fullURL() throws -> URL
Return Value
The URL for this resource.
-
resourceURL(ofType:bundle:)
Extension methodGet the URL for a given resource. This can return either a URL to an online resource or a URL for an embedded resource.
Throws
RSDResourceTransformerError
if the file cannot be found.Declaration
Swift
public func resourceURL(ofType defaultExtension: String? = nil, bundle: Bundle? = nil) throws -> (url: URL, resourceType: RSDResourceType)
Parameters
defaultExtension
The default extension for the URL. If
nil
then theresourceName
will be inspected for a file extension. If that isnil
thenjson
will be assumed.bundle
The bundle to use for fetching the resource. If
nil
then theRSDResourceConfig
will be used.Return Value
- url: The returned URL for this resource.
- resourceType: The resource type.
-
resourceData(ofType:bundle:)
Extension methodGet the
Data
for a given resource. This is used to get data from an embedded resource.Throws
RSDResourceTransformerError
if the file cannot be found.Declaration
Swift
public func resourceData(ofType defaultExtension: String? = nil, bundle: Bundle? = nil) throws -> (data: Data, resourceType: RSDResourceType)
Parameters
defaultExtension
The default extension for the URL. If
nil
then theresourceName
will be inspected for a file extension. If that isnil
thenjson
will be assumed.bundle
The bundle to use for fetching the resource. If
nil
then theRSDResourceConfig
will be used.Return Value
- data: The returned Data for this resource.
- resourceType: The resource type.