mirror of
https://github.com/swift-server/RediStack.git
synced 2026-06-02 07:37:33 +00:00
Motivation: Johannes provided a fair code review of the project and summarized his findings in issue #48, and one of the prime offenders was all of the `unsafe*` APIs (pointers, buffers, bytes) that were used with `RESPValue` and `RESPValueConvertible`. He also provided great feedback and pointed out good points of confusion with the API design of `RESPValue` and `RESPValueConvertible`. Modifications: - Return to using `Array` instead of `ContiguousArray` for `RESPValue.array` storage - Update all documentation to be more thorough in explaining how the types should be used and conformed to. - Remove all uses of `unsafe*` APIs where possible - Change implementations to be a lot more type and memory safe, double checking assumptions - Remove conformance to `ExpressibleBy*Literal` as it is too easy for users to shoot themselves in the foot and saves only a few characters over `.init(bulk:)` - Create new `RedisNIOTestUtils` target for common test extensions, making them public - Move most almost all implementations of `RESPValue` computed properties into the `RESPValueConvertible` conformances Result: Users should be more safeguarded by the API against unknowingly getting incorrect `RESPValue` representations, the API design of `RESPValue` and `RESPValueConvertible` should be much clearer, and memory safety should be at a higher bar from these changes. This resolves issues #55 & #48, and contributes to issue #47.
34 lines
1.2 KiB
Swift
34 lines
1.2 KiB
Swift
// swift-tools-version:5.0
|
|
//===----------------------------------------------------------------------===//
|
|
//
|
|
// This source file is part of the RedisNIO open source project
|
|
//
|
|
// Copyright (c) 2019 RedisNIO project authors
|
|
// Licensed under Apache License v2.0
|
|
//
|
|
// See LICENSE.txt for license information
|
|
// See CONTRIBUTORS.txt for the list of RedisNIO project authors
|
|
//
|
|
// SPDX-License-Identifier: Apache-2.0
|
|
//
|
|
//===----------------------------------------------------------------------===//
|
|
|
|
import PackageDescription
|
|
|
|
let package = Package(
|
|
name: "swift-redis-nio-client",
|
|
products: [
|
|
.library(name: "RedisNIO", targets: ["RedisNIO"])
|
|
],
|
|
dependencies: [
|
|
.package(url: "https://github.com/apple/swift-log.git", from: "1.0.0"),
|
|
.package(url: "https://github.com/apple/swift-metrics.git", from: "1.0.0"),
|
|
.package(url: "https://github.com/apple/swift-nio.git", from: "2.0.0")
|
|
],
|
|
targets: [
|
|
.target(name: "RedisNIO", dependencies: ["NIO", "Logging", "Metrics"]),
|
|
.target(name: "RedisNIOTestUtils", dependencies: ["NIO", "RedisNIO"]),
|
|
.testTarget(name: "RedisNIOTests", dependencies: ["RedisNIO", "NIO", "RedisNIOTestUtils"])
|
|
]
|
|
)
|