Get it working without images

This commit is contained in:
Stuart Tett
2017-11-16 15:33:28 -08:00
parent 7251106acc
commit d9c3c9150d
4 changed files with 35 additions and 42 deletions
+1
View File
@@ -31,3 +31,4 @@ Pods
# Carthage
Carthage
/.build
+16
View File
@@ -0,0 +1,16 @@
{
"object": {
"pins": [
{
"package": "SwiftHash",
"repositoryURL": "https://github.com/onmyway133/SwiftHash.git",
"state": {
"branch": null,
"revision": "1387bd2a614060ff516b3aa1279354b139b3e6f1",
"version": "2.0.1"
}
}
]
},
"version": 1
}
+18 -10
View File
@@ -1,22 +1,30 @@
// swift-tools-version:4.0
// The swift-tools-version declares the minimum version of Swift required to build this package.
import PackageDescription
var package = Package(
let package = Package(
name: "Cache",
products: [
.library(
name: "Cache",
targets: ["Cache"]
)
// Products define the executables and libraries produced by a package, and make them visible to other packages.
.library(
name: "Cache",
targets: ["Cache"]),
],
dependencies: [
.package(url: "https://github.com/onmyway133/SwiftHash.git", .upToNextMinor(from: "2.0.0")),
// Dependencies declare other packages that this package depends on.
.package(url: "https://github.com/onmyway133/SwiftHash.git", .upToNextMinor(from: "2.0.0")),
],
targets: [
.target(
name: "Cache",
dependencies: ["Cache"]
)
// Targets are the basic building blocks of a package. A target can define a module or a test suite.
// Targets can depend on other targets in this package, and on products in packages which this package depends on.
.target(
name: "Cache",
dependencies: ["SwiftHash"],
path: "Source/Shared"),
.testTarget(
name: "CacheTests",
dependencies: ["Cache"],
path: "Tests"),
]
)
-32
View File
@@ -1,32 +0,0 @@
import Foundation
public struct ImageWrapper: Codable {
public let image: Image
public enum CodingKeys: String, CodingKey {
case image
}
public init(image: Image) {
self.image = image
}
public init(from decoder: Decoder) throws {
let container = try decoder.container(keyedBy: CodingKeys.self)
let data = try container.decode(Data.self, forKey: CodingKeys.image)
guard let image = Image(data: data) else {
throw StorageError.decodingFailed
}
self.image = image
}
public func encode(to encoder: Encoder) throws {
var container = encoder.container(keyedBy: CodingKeys.self)
guard let data = image.cache_toData() else {
throw StorageError.encodingFailed
}
try container.encode(data, forKey: CodingKeys.image)
}
}