mirror of
https://github.com/hyperoslo/Cache.git
synced 2026-04-07 19:17:36 +00:00
Get it working without images
This commit is contained in:
@@ -31,3 +31,4 @@ Pods
|
||||
|
||||
# Carthage
|
||||
Carthage
|
||||
/.build
|
||||
|
||||
@@ -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
@@ -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"),
|
||||
]
|
||||
)
|
||||
|
||||
@@ -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)
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user